1
Q:

how to get a clock in java

Code:
// create a Zone Id for Europe/Paris
ZoneId zoneId = ZoneId.of("Europe/Paris");

// base Clock with default zone
Clock realClock=Clock.system(zoneId);
System.out.println(clock.instant());

Output:: 
2018-08-21T10:25:52.361Z

Explanation:: 
when you call system(ZoneId) for Clock then the system(ZoneId)
method will return a Class Object for the given ZoneId.you can get
date and time of clock by using instant of class.
0

New to Communities?

Join the community