// Used for "toMillis":
import java.util.concurrent.TimeUnit;

public class elapsedTime {
 
  public static void main(String[] args) { 

    // Next line is from:
    //   https://docs.oracle.com/javase/6/docs/api/java/lang
    //     /System.html#nanoTime%28%29
    long startTime = System.nanoTime();    

    System.out.println("Hello world!");

    // Next line is from:
    //   https://docs.oracle.com/javase/6/docs/api/java/lang
    //     /System.html#nanoTime%28%29
    long estimatedTime = System.nanoTime() - startTime;

    System.out.println("elapsed time: " + estimatedTime + " ns");
    // Convert ns to micro-seconds, then micro-seconds to ms
    System.out.println("elapsed time: " + (estimatedTime/1000.0)/1000.0 + " ms");

    // "toMillis" call is from:
    //   Kevin Bourrillion
    //   Nov 2, 2014 at 16:51
    //   https://stackoverflow.com/questions/1770010/how-do-i-measure-
    //     time-elapsed-in-java
    System.out.println("elapsed time: " + 
      TimeUnit.NANOSECONDS.toMillis(estimatedTime) + " ms");
  }

}

