Java Date Time - Java Calendar.getTimeInMillis()








Syntax

Calendar.getTimeInMillis() has the following syntax.

public long getTimeInMillis()

Example

In the following code shows how to use Calendar.getTimeInMillis() method.

//from   w ww.jav a2  s.c o  m

import java.util.Calendar;

public class Main {

   public static void main(String[] args) throws InterruptedException {

      Calendar cal = Calendar.getInstance();

      // print current time in milliseconds
      System.out.println("Current time is : " + cal.getTimeInMillis());


   }
}

The code above generates the following result.