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






Get elapsed time in milliseconds

  

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

    Thread.sleep(2000);

    long elapsedTimeMillis = System.currentTimeMillis() - start;
    System.out.println(elapsedTimeMillis);
  }
}

   
    
  








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 seconds
5.Get elapsed time in minutes
6.Get elapsed time in hours
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