GregorianCalendar getTimeInMillis() in Java

getTimeInMillis(): This method is available in java.util.GregorianCalendar class of Java.

Syntax:

long java.util.Calendar.getTimeInMillis()

This method returns this Calendar's time value in milliseconds.

Parameters: NA

Returns: the current time as UTC milliseconds from the epoch.

Exceptions: NA

Approach

Java

import java.util.GregorianCalendar;

public class GregorianCalendargetTimeInMillis {
    public static void main(String[] args) {

        GregorianCalendar cal = new GregorianCalendar();

        System.out.println(cal.getTimeInMillis());
    }
}

Output:

1644163598586


No comments:

Post a Comment