Java Calendar getTimeInMillis() Method

The getTimeInMillis() method of java.util.Calendar class returns the current time in millisecond. This method returns a long value.

Syntax

Parameter

No parameter is passed.

Returns

The current time as UTC milliseconds.

Throws

Throws InterruptedException

Example 1

Output:

Current time : Wed Aug 08 21:54:18 PDT 2018
Current time in Millis : 1533790458542
Next time is : 1533790458620

Example 2

Output:

Current time in Millis : 1533791120506
Current time in Millis  after adding 20 hours : 1533863120506
Next time is : 1533791120539