Example usage for java.time ZonedDateTime withEarlierOffsetAtOverlap

List of usage examples for java.time ZonedDateTime withEarlierOffsetAtOverlap

Introduction

In this page you can find the example usage for java.time ZonedDateTime withEarlierOffsetAtOverlap.

Prototype

@Override
public ZonedDateTime withEarlierOffsetAtOverlap() 

Source Link

Document

Returns a copy of this date-time changing the zone offset to the earlier of the two valid offsets at a local time-line overlap.

Usage

From source file:Main.java

public static void main(String[] args) {
    ZonedDateTime dateTime = ZonedDateTime.now();
    ZonedDateTime l = dateTime.withEarlierOffsetAtOverlap();
    System.out.println(l);//from  ww w .j a  v  a2 s.co m
}

From source file:Main.java

public static void main(String[] args) {
    ZoneId usChicago = ZoneId.of("America/Chicago");

    // 2014-03-09T02:30 did not exist in America/Chicago time zone
    LocalDateTime ldt = LocalDateTime.of(2014, Month.MARCH, 9, 2, 30);
    ZonedDateTime zdt = ZonedDateTime.of(ldt, usChicago);
    System.out.println(zdt);//w w  w . j a  va  2 s . co m

    // 2013-10-03T01:30 existed twice in America/Chicago time zone
    LocalDateTime ldt2 = LocalDateTime.of(2013, Month.NOVEMBER, 3, 1, 30);
    ZonedDateTime zdt2 = ZonedDateTime.of(ldt2, usChicago);

    System.out.println(zdt2.withEarlierOffsetAtOverlap());
    System.out.println(zdt2.withLaterOffsetAtOverlap());

}