Close

Java Date Time - Clock.system() Examples

Java Date Time Java Java API 


Class:

java.time.Clock

java.lang.Objectjava.lang.Objectjava.time.Clockjava.time.ClockLogicBig

Method:

public static Clock system(ZoneId zone)

Creates a clock that returns the current instant using best available system clock. The clock uses the specified time-zone.


Examples


package com.logicbig.example.clock;

import java.time.Clock;
import java.time.ZoneId;

public class SystemExample {

public static void main(String... args) {
Clock c = Clock.system(ZoneId.of("Australia/Sydney"));
System.out.println(c);
}
}

Output

SystemClock[Australia/Sydney]




See Also