Correct Way of Calculating Elapsed Time in Java

You may also like...

Leave a Reply

1 Comment on "Correct Way of Calculating Elapsed Time in Java"

avatar
  Subscribe  
newest oldest
Notify of
Nathaniel M
Guest
Nathaniel M

public String toMinuteSeconds(){
return String.format(“%d min, %d sec”, time(TimeUnit.MINUTES),
time(TimeUnit.SECONDS) – (time(TimeUnit.MINUTES) * 60));
}

The original didn’t have the ” * 60″, so the seconds didn’t subtract correctly.