The static currentTimeMillis()
method from the java.lang.System
class is used to get the current program execution time in milliseconds. The millisecond will be returned as a unit of time. The value in milliseconds also depends on the underlying operating system and system architecture.
static long currentTimeMillis()
The function does not take any parameter.
milliseconds
: It returns the time difference between the current time and midnight on January 1, 1970 UTC in milliseconds.
Note: Milliseconds are represented as
ms
.
// Program to check currentTimeMillis() method executionpublic class Edpresso {// main methodpublic static void main(String[] args) {// Calling currentTimeMillis() methodSystem.out.println("Current time:"+ " " + System.currentTimeMillis() + "ms");}}
System.currentTimeMillis()
is called for the current time.