Clock withZone(ZoneId zone)
returns a copy of
this clock with a different time-zone.
withZone
has the following syntax.
public abstract Clock withZone(ZoneId zone)
The following example shows how to use withZone
.
import java.time.Clock; import java.time.ZoneId; /*www . j av a2s. co m*/ public class Main { public static void main(String[] args) { Clock clock = Clock.systemUTC(); System.out.println(clock.getZone()); clock.withZone(ZoneId.systemDefault()); System.out.println(clock.getZone()); } }
The code above generates the following result.