Java Calendar - getTimeInMillis() Method
The java.util.Calendar.getTimeInMillis() method returns this Calendar's time value in milliseconds.
Syntax
public long getTimeInMillis()
Parameters
No parameter is required.
Return Value
Returns the current time as UTC milliseconds from the epoch.
Exception
NA.
Example:
In the example below, the java.util.Calendar.getTimeInMillis() method returns the given Calendar's time value in milliseconds.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a Calendar object with specified date Calendar Cal = new GregorianCalendar(2015, 1, 25); //printing the Calendar System.out.println("The Calendar is: " + Cal.getTime()); //printing the time value in milliseconds System.out.println("Time Value in Milliseconds: " + Cal.getTimeInMillis()); } }
The output of the above code will be:
The Calendar is: Wed Feb 25 00:00:00 UTC 2015 Time Value in Milliseconds: 1424822400000
❮ Java.util - Calendar