how to get current time in milliseconds in java code example

Example 1: java get current time in milliseconds

public class CurrentTimeInMilliseconds
{
   public static void main(String[] args) 
   {
      // returning current time in milliseconds
      System.out.println("Current time in milliseconds: " + System.currentTimeMillis());
   }
}

Example 2: java get current milliseconds

package com.tutorialspoint;

import java.lang.*;

public class SystemDemo {

   public static void main(String[] args) {

      // returns the current time in milliseconds
      System.out.print("Current Time in milliseconds = ");
      System.out.println(System.currentTimeMillis());
   }
}

Tags:

Java Example