How to Get System Time in Java


In this example we will show how to get the system time using currentTimeMillis method of java System class.

Source Code

package com.beginner.examples;

 
public class SystemTimeExample {
	
	public static void main(String args[])
	{		 
		//get system time
		long time = System.currentTimeMillis();
		 
		System.out.println("Milliseconds is " + time + " since January 1, 1970 UTC.");
	}
 
}

Output:

Milliseconds is 1559096869005 since January 1, 1970 UTC.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments