Ascalonian
Programmer
I am trying to calculate the time it took for my validation method to start and stop. I wrote some code that I thought should have worked, but the output seems way off. My code and output is below.
And the output is:
Any ideas why there is a 19 in the Total time? I would think that Total Time should be 00:00:08
Code:
long startTime = System.currentTimeMillis();
...
long endTime = System.currentTimeMillis();
long elapsedTime = endTime - startTime;
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("EST"));
System.out.println("Start Time: " + dateFormat.format(new Date(startTime)));
System.out.println("End Time: " + dateFormat.format(new Date(endTime)));
System.out.println("Total Time: " + dateFormat.format(new Date(elapsedTime)));
And the output is:
Code:
Start Time: 09:52:04
End Time: 09:52:13
Total Time: 19:00:08
Any ideas why there is a 19 in the Total time? I would think that Total Time should be 00:00:08