System.currentTimeMillis() in Java

System.currentTimeMillis(): This method is available in java.lang.System class of Java.

Syntax:

long java.lang.System.currentTimeMillis()

This method returns the current time in milliseconds.

Parameters: NA

Returns: the difference, measured in milliseconds, between the current time and midnight, January 1, 1970, UTC.

Exceptions: NA

Approach

Java

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

        System.out.println(System.currentTimeMillis());
    }
}

Output:

1633507912677

No comments:

Post a Comment