title: Loop in csv file
body: <p>I asked this question before however I did not get the answer that I expected. Therefore I opened this new question.</p>
  
  <p>My try:</p>
  
  <pre><code>    String fileName = "placements.csv";
          try {
            // Assume default encoding.
            FileWriter fileWriter = new FileWriter(fileName);
  
            // Always wrap FileWriter in BufferedWriter.
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            // First row, write the head of the csv file.
            bufferedWriter.write(FILE_HEADER);
            bufferedWriter.newLine();
            // Increase the begin date 1 seconds until test end date.
            int seconds = 0;
            Calendar cal = Calendar.getInstance();
            cal.setTime(beginDate);
            for (int j = 0; j &lt; convertedDifference; j++) {
              for (Job currentJob : NEHCalculator.sequenceOrderListofJobs()) {
  
                int times = (int) ((convertedDifference / currentJob.getInterval()) * testDevices());
  
                for (int i = 0; i &lt; currentJob.getNeededTestTime() * times; i++) {
  
                  cal.add(Calendar.SECOND, 1);
                  beginDate.getTime();
                  // write the test date
                  bufferedWriter.write(String.valueOf(cal.getTime()));
                  bufferedWriter.write(";");
                  bufferedWriter.write(String.valueOf(seconds));
                  bufferedWriter.write(";");
                  bufferedWriter.write(currentJob.getJobname());
                  bufferedWriter.write(";");
                  bufferedWriter.newLine();
                }// end of currentjob loop
                seconds++;
              }// end first for loop
            }
            bufferedWriter.close();// Always close files.
  
          } catch (IOException ex) {
            System.out.println("Error writing to file '" + fileName);
          }  
  }
  </code></pre>
  
  <p>First for loop <code>for (int j = 0; j &lt; convertedDifference; j++)</code> : I restrict my program until test end date. If I enter 1 hour test time, i expected to see number 0 until 3599 seconds.</p>
  
  <p>Second for loop <code>for (Job currentJob : NEHCalculator.sequenceOrderListofJobs())</code>: I want to test every devices in the list.</p>
  
  <p>For third for loop <code>for (int i = 0; i &lt; currentJob.getNeededTestTime() * times; i++)</code>: I expected to test first job <code>currentJob.getNeededTestTime() * times times</code>.</p>
  
  <p>For example I have 1 hour test time and interval of fist job is 15 min and it tests 2 devices and test needed time 2 seconds. So the output must be:</p>
  
  <pre><code>Mon Feb 22 12:59:59 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:00 CET 2016;1;WAF5-H;
  Mon Feb 22 13:00:01 CET 2016;2;WAF5-H;
  Mon Feb 22 13:00:02 CET 2016;3;WAF5-H;
  Mon Feb 22 13:00:03 CET 2016;4;WAF5-H;
  Mon Feb 22 13:00:04 CET 2016;5;WAF5-H;
  Mon Feb 22 13:00:05 CET 2016;6;WAF5-H;
  Mon Feb 22 13:00:06 CET 2016;7;WAF5-H;
  Mon Feb 22 13:00:07 CET 2016;8;WAF5-H;
  Mon Feb 22 13:00:08 CET 2016;9;WAF5-H;
  Mon Feb 22 13:00:09 CET 2016;10;WAF5-H;
  Mon Feb 22 13:00:10 CET 2016;11;WAF5-H; 
  Mon Feb 22 13:00:11 CET 2016;12;WAF5-H; 
  Mon Feb 22 13:00:12 CET 2016;13;WAF5-H; 
  Mon Feb 22 13:00:13 CET 2016;14;WAF5-H; 
  Mon Feb 22 13:00:14 CET 2016;15;WAF5-H; then it will continue with second job until end of the job list.
  </code></pre>
  
  <p>However the output of my code is:</p>
  
  <pre><code>Mon Feb 22 12:59:59 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:00 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:01 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:02 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:03 CET 2016;0;WAF5-H;
  Mon Feb 22 13:00:04 CET 2016;2;WAF5-H;
  Mon Feb 22 13:00:05 CET 2016;2;WAF5-H;
  Mon Feb 22 13:00:06 CET 2016;2;WAF5-H;
  Mon Feb 22 13:00:07 CET 2016;2;WAF5-H;
  Mon Feb 22 13:00:08 CET 2016;2;WAF5-H; until Mon Feb 22 17:55:08 CET 2016;7082;WAF5-H;
  </code></pre>
  
  <p>It is completely wrong and I spend really so soo much time but I failed with this task. Could someone please help me.</p>
  
  <p>Best regards,</p>