ChronoZonedDateTime withLaterOffsetAtOverlap() method in Java with Examples
The withLaterOffsetAtOverlap() method of a ChronoZonedDateTime interface is used to return a copy of this ChronoZonedDateTime object after changing the zone offset to the later of the two valid offsets at a local time-line overlap. The overlap happens when Daylight saving time finishes and one hour is returned to the timeline. FDue to this there are two valid offsets for the local date-time and calling withLaterOffsetAtOverlap method will return a ChronoZonedDateTime with the later of the two zones. If this method is called when it is not an overlap, this is returned. This instance is immutable and unaffected by this method call.
Syntax:
ChronoZonedDateTime withLaterOffsetAtOverlap()
Parameters: This method accepts no parameters.
Return value: This method returns a ChronoZonedDateTime based on this date-time with the later offset.
Below programs illustrate the withLaterOffsetAtOverlap() method:
Program 1:
// Java program to demonstrate // ChronoZonedDateTime.withLaterOffsetAtOverlap() method import java.time.*; import java.time.chrono.*; public class GFG { public static void main(String[] args) { // create a ChronoZonedDateTime object ChronoZonedDateTime zonedDT = ZonedDateTime.of( LocalDateTime.of(2018, 11, 4, 1, 25, 43), ZoneId.of("US/Central")); // print ChronoZonedDateTime System.out.println("Before withLaterOffsetAtOverlap(): " + zonedDT); // apply withLaterOffsetAtOverlap() ChronoZonedDateTime zonedDT2 = zonedDT.withLaterOffsetAtOverlap(); // print ChronoZonedDateTime // after withLaterOffsetAtOverlap() System.out.println("After withLaterOffsetAtOverlap(): " + zonedDT2); } } |
Before withLaterOffsetAtOverlap(): 2018-11-04T01:25:43-05:00[US/Central] After withLaterOffsetAtOverlap(): 2018-11-04T01:25:43-06:00[US/Central]
Program 2:
// Java program to demonstrate // ChronoZonedDateTime.withLaterOffsetAtOverlap() method import java.time.*; import java.time.chrono.*; public class GFG { public static void main(String[] args) { // create a ChronoZonedDateTime object ChronoZonedDateTime zonedDT = ZonedDateTime.of( LocalDateTime.of(2021, 11, 07, 1, 05, 53), ZoneId.of("US/Central")); // print ChronoZonedDateTime System.out.println("Before withLaterOffsetAtOverlap(): " + zonedDT); // apply withLaterOffsetAtOverlap() ChronoZonedDateTime zonedDT2 = zonedDT.withLaterOffsetAtOverlap(); // print ChronoZonedDateTime // after withLaterOffsetAtOverlap() System.out.println("After withLaterOffsetAtOverlap(): " + zonedDT2); } } |
Before withLaterOffsetAtOverlap(): 2021-11-07T01:05:53-05:00[US/Central] After withLaterOffsetAtOverlap(): 2021-11-07T01:05:53-06:00[US/Central]
Recommended Posts:
- ZonedDateTime withLaterOffsetAtOverlap() method in Java with Examples
- ChronoZonedDateTime until() method in Java with Examples
- ChronoZonedDateTime get() method in Java with Examples
- ChronoZonedDateTime from() method in Java with Examples
- ChronoZonedDateTime toLocalDate() method in Java with Examples
- ChronoZonedDateTime query() method in Java with Examples
- ChronoZonedDateTime isBefore() method in Java with Examples
- ChronoZonedDateTime toLocalTime() method in Java with Examples
- ChronoZonedDateTime getOffset() method in Java with Examples
- ChronoZonedDateTime getLong() method in Java with Examples
- ChronoZonedDateTime toEpochSecond() method in Java with Examples
- ChronoZonedDateTime getChronology() method in Java with Examples
- ChronoZonedDateTime withZoneSameLocal() method in Java with Examples
- ChronoZonedDateTime range() method in Java with Examples
- ChronoZonedDateTime toInstant() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



