List of usage examples for java.time ZoneId of
public static ZoneId of(String zoneId)
From source file:Main.java
public static void main(String[] args) { ZonedDateTime _130AMChicagoTime = ZonedDateTime.of(2014, 3, 9, 1, 30, 0, 0, ZoneId.of("America/Chicago")); System.out.println(_130AMChicagoTime.plusHours(3)); System.out.println(_130AMChicagoTime.plus(Duration.ofHours(3))); System.out.println(_130AMChicagoTime.plus(Duration.ofDays(2))); System.out.println(_130AMChicagoTime.plus(Period.ofDays(2))); }
From source file:Main.java
public static void main(String[] args) { // Time Zone//from w w w .j ava 2s. c om ZoneId zone = ZoneId.systemDefault(); System.out.println(Clock.system(zone)); System.out.println(Clock.system(ZoneId.of("Europe/Berlin"))); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime leaving = LocalDateTime.of(2013, Month.JULY, 20, 19, 30); ZoneId leavingZone = ZoneId.of("America/Los_Angeles"); ZonedDateTime departure = ZonedDateTime.of(leaving, leavingZone); System.out.println(departure); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime ldt = LocalDateTime.of(2014, Month.JUNE, 21, 16, 30); ZoneId usCentral = ZoneId.of("America/Chicago"); ZonedDateTime zdt = ZonedDateTime.of(ldt, usCentral); System.out.println("In US Central Time Zone:" + zdt); ZoneId losAngeles = ZoneId.of("America/Los_Angeles"); ZonedDateTime zdt2 = zdt.withZoneSameInstant(losAngeles); System.out.println("In America/Los_Angeles Time Zone:" + zdt2); }
From source file:Main.java
public static void main(String[] args) { Instant instant = Instant.now(); LocalDateTime dateTimeFromInstant = LocalDateTime.ofInstant(instant, ZoneId.of("America/Los_Angeles")); Instant instantFromDateTime = LocalDateTime.now().toInstant(ZoneOffset.ofHours(-2)); System.out.println(dateTimeFromInstant); System.out.println(instantFromDateTime); }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime zonedDateTime = ZonedDateTime.of(2013, 1, 19, 0, 0, 0, 0, ZoneId.of("Europe/Paris")); DateTimeFormatter longDateTimeFormatter = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL).withLocale(Locale.FRENCH); System.out.println(longDateTimeFormatter.getLocale()); // fr System.out.println(longDateTimeFormatter.format(zonedDateTime)); }
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2013, 11, 12); LocalTime localTime = LocalTime.of(23, 10, 44, 12882); ZoneId chicago = ZoneId.of("America/Chicago"); ZonedDateTime chicagoTime = ZonedDateTime.of(localDate, localTime, chicago); System.out.println(chicagoTime); }
From source file:Main.java
public static void main(String[] args) { LocalDateTime localDateTime = LocalDateTime.of(1982, Month.APRIL, 17, 14, 11); ZonedDateTime jakartaTime = ZonedDateTime.of(localDateTime, ZoneId.of("Asia/Jakarta")); System.out.println(jakartaTime); //1982-04-17T14:11+07:00[Asia/Jakarta] System.out.println(jakartaTime.withZoneSameInstant(ZoneId.of("America/Los_Angeles"))); //1982-04-16T23:11-08:00[America/Los_Angeles] System.out.println(jakartaTime.withZoneSameLocal(ZoneId.of("America/New_York"))); //1982-04-17T14:11-05:00[America/New_York] }
From source file:Main.java
public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); ZoneId usChicago = ZoneId.of("America/Chicago"); System.out.println("Zone ID: " + usChicago.getId()); ZoneRules rules = usChicago.getRules(); System.out.println("isFixedOffset(): " + rules.isFixedOffset()); ZoneOffset offset = rules.getOffset(now); System.out.println("Zone offset: " + offset); List<ZoneOffsetTransition> transitions = rules.getTransitions(); System.out.println(transitions); }
From source file:Main.java
public static void main(String[] args) { ZonedDateTime z = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault()); System.out.println(z);//from ww w . j a v a 2 s . com LocalDateTime timePoint = LocalDateTime.now(); ZoneId id = ZoneId.of("Europe/Paris"); ZonedDateTime zoned = ZonedDateTime.of(timePoint, id); System.out.println(zoned); }