Get elapsed time in hours : Timing « Development Class « Java






Get elapsed time in hours

  

public class Main {
  public static void main(String[] argv) throws Exception {
    long start = System.currentTimeMillis();

    Thread.sleep(2000);

    // Get elapsed time in milliseconds
    long elapsedTimeMillis = System.currentTimeMillis() - start;
    
    // Get elapsed time in hours
    float elapsedTimeHour = elapsedTimeMillis/(60*60*1000F);
    System.out.println(elapsedTimeHour);
  }
}

   
    
  








Related examples in the same category

1.Compute and display elapsed time of an operation
2.Get system time using System class
3.Class for program event timing
4.Get elapsed time in milliseconds
5.Get elapsed time in seconds
6.Get elapsed time in minutes
7.Get elapsed time in days
8.Get time in milliseconds using Java Calendar
9.java.util.concurrent.TimeUnit: convert between milliseconds and days
10.Get seconds since