List of usage examples for java.time Clock systemUTC
public static Clock systemUTC()
From source file:Main.java
public static void main(String[] args) { OffsetTime m = OffsetTime.now(Clock.systemUTC()); System.out.println(m); }
From source file:Main.java
public static void main(String[] args) { LocalTime nowInUtc = LocalTime.now(Clock.systemUTC()); System.out.println(nowInUtc); // 06:08:18.125 }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime z = ZonedDateTime.now(Clock.systemUTC()); System.out.println(z); }
From source file:Main.java
public static void main(String[] args) { OffsetDateTime o = OffsetDateTime.now(Clock.systemUTC()); System.out.println(o); }
From source file:Main.java
public static void main(String[] args) { // Current Time Clock clock = Clock.systemUTC(); System.out.println(Clock.systemDefaultZone()); LocalDateTime dateAndTime = LocalDateTime.now(clock); System.out.println(dateAndTime); System.out.println(LocalDateTime.now()); }
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);/*from ww w. j a va2s . com*/ 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)); }
From source file:Main.java
public static void main(String[] args) { // the current date LocalDate currentDate = LocalDate.now(); // 2014-02-10 LocalDate tenthFeb2014 = LocalDate.of(2014, Month.FEBRUARY, 10); // months values start at 1 (2014-08-01) LocalDate firstAug2014 = LocalDate.of(2014, 8, 1); // the 65th day of 2010 (2010-03-06) LocalDate sixtyFifthDayOf2010 = LocalDate.ofYearDay(2010, 65); // times, e.g. 19:12:30.733 LocalTime currentTime = LocalTime.now(); // current time LocalTime midday = LocalTime.of(12, 0); // 12:00 LocalTime afterMidday = LocalTime.of(13, 30, 15); // 13:30:15 // 12345th second of day (03:25:45) LocalTime fromSecondsOfDay = LocalTime.ofSecondOfDay(12345); // dates with times, e.g. 2014-02-18T19:08:37.950 LocalDateTime currentDateTime = LocalDateTime.now(); // 2014-10-02 12:30 LocalDateTime secondAug2014 = LocalDateTime.of(2014, 10, 2, 12, 30); // 2014-12-24 12:00 LocalDateTime christmas2014 = LocalDateTime.of(2014, Month.DECEMBER, 24, 12, 0); // current (local) time in Los Angeles LocalTime currentTimeInLosAngeles = LocalTime.now(ZoneId.of("America/Los_Angeles")); // current time in UTC time zone LocalTime nowInUtc = LocalTime.now(Clock.systemUTC()); System.out.println("date/time creation: currentDate: " + currentDate); System.out.println("date/time creation: tenthFeb2014: " + tenthFeb2014); System.out.println("date/time creation: firstAug2014: " + firstAug2014); System.out.println("date/time creation: sixtyFifthDayOf2010: " + sixtyFifthDayOf2010); System.out.println("date/time creation: currentTime: " + currentTime); System.out.println("date/time creation: midday: " + midday); System.out.println("date/time creation: afterMidday: " + afterMidday); System.out.println("date/time creation: fromSecondsOfDay: " + fromSecondsOfDay); System.out.println("date/time creation: currentTimeInLosAngeles: " + currentTimeInLosAngeles); System.out.println("date/time creation: currentDateTime: " + currentDateTime); System.out.println("date/time creation: secondAug2014: " + secondAug2014); System.out.println("date/time creation: christmas2014: " + christmas2014); }
From source file:com.oharemza.timeteller.TimeTellerController.java
public TimeTellerController() { this.clock = Clock.systemUTC(); }
From source file:com.opentable.pausedetector.JvmPauseAlarmConfiguration.java
@Bean public JvmPauseAlarm jvmPauseAlarm() { return new JvmPauseAlarm(clock.orElse(Clock.systemUTC())::instant, checkTime.toMillis(), pauseAlarmTime.toMillis(), (t) -> { });//from www .j a va 2 s . c om }
From source file:alfio.controller.api.support.PublicCategory.java
public boolean isActive() { ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC()); return category.getUtcInception().isBefore(now) && now.isBefore(category.getUtcExpiration()); }