Get Current Time in Java

Tags: Time

In this Java core tutorial, we learn how to get current time in milliseconds in a Java program.

Using System.currentTimeMillis() static method

CurrentTimeExample.java

public class CurrentTimeExample {
    public static void main(String[] args) {
        long currentTime = System.currentTimeMillis();

        System.out.println(currentTime + " Milliseconds");
    }
}
The output is:
1610032553435 Milliseconds

Happy Coding 😊