List of usage examples for java.time Clock offset
public static Clock offset(Clock baseClock, Duration offsetDuration)
This clock wraps another clock, returning instants that are later by the specified duration.
From source file:Main.java
public static void main(String[] args) { Clock clock = Clock.systemUTC(); Duration duration = Duration.ofHours(3); Clock newClock = Clock.offset(clock, duration); System.out.println(newClock.instant()); }
From source file:Main.java
public static void main(String[] args) { Clock utcClock = Clock.systemUTC(); Clock defaultClock = Clock.systemDefaultZone(); Clock offsetClock = Clock.offset(Clock.systemUTC(), Duration.ofHours(-5)); ZoneId denverTimeZone = ZoneId.of("America/Denver"); ZoneId newYorkTimeZone = ZoneId.of("America/New_York"); ZoneId chicagoTimeZone = ZoneId.of("America/Chicago"); ZoneId losAngelesTimeZone = ZoneId.of("America/Los_Angeles"); Instant instant = Instant.now(defaultClock); Instant instant2 = Instant.now(utcClock); Instant instant3 = Instant.now(offsetClock); System.out.println(instant);// w ww . jav a 2 s . c o m System.out.println(instant2); System.out.println(instant3.plus(Duration.ofSeconds(90))); System.out.println(instant3.atZone(newYorkTimeZone)); System.out.println(instant3.atZone(chicagoTimeZone)); System.out.println(instant3.atZone(denverTimeZone)); System.out.println(instant3.atZone(losAngelesTimeZone)); }