Close

Java Date Time - Clock.withZone() Examples

Java Date Time Java Java API 


Class:

java.time.Clock

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

Method:

public abstract Clock withZone(ZoneId zone)

Returns a copy of this clock with the specified time-zone.


Examples


package com.logicbig.example.clock;

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

public class WithZoneExample {

public static void main(String... args) {
Clock c = Clock.systemDefaultZone();
System.out.println(c);

Clock c2 = c.withZone(ZoneId.of("Asia/Seoul"));
System.out.println(c2);
}
}

Output

SystemClock[America/Chicago]
SystemClock[Asia/Seoul]




See Also