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






Get elapsed time in days

  

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;

    float elapsedTimeDay = elapsedTimeMillis/(24*60*60*1000F);
    System.out.println(elapsedTimeDay);
  }
}

   
    
  








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 hours
8.Get time in milliseconds using Java Calendar
9.java.util.concurrent.TimeUnit: convert between milliseconds and days
10.Get seconds since