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  .j  av  a  2 s. c  om*/

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.