Java Program to display computer time in milliseconds


Use currentTimeMillis() method in Java to display the computer time in milliseconds.

Here we are getting the milliseconds in long type −

long res = System.currentTimeMillis();

The following is an example −

Example

 Live Demo

public class Demo {
   public static void main(String[] a) {
      long res = System.currentTimeMillis();
      System.out.println(res);
   }
}

Output

1543142485568
raja
Published on 21-Dec-2018 11:19:09
Advertisements