ZonedDateTime withFixedOffsetZone() method in Java with Examples Last Updated : 17 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The withFixedOffsetZone() method of a ZonedDateTime class is used to return a copy of this ZonedDateTime object with the zone ID set to the offset. This method returns a ZonedDateTime where the zone ID is the same as getOffset().The local date-time, offset and instant of the returned ZonedDateTime will be the same as in this date-time. Syntax: public ZonedDateTime withFixedOffsetZone() Parameters: This method accepts no parameters. Return value: This method returns a ZonedDateTime with the zone ID set to the offset. Below programs illustrate the withFixedOffsetZone() method: Program 1: Java // Java program to demonstrate // ZonedDateTime.withFixedOffsetZone() method import java.time.*; public class GFG { public static void main(String[] args) { // create a ZonedDateTime object ZonedDateTime zonedDT = ZonedDateTime .ofLocal( LocalDateTime.of(2018, 11, 4, 1, 25, 43), ZoneId.of("US/Central"), ZoneOffset.ofHours(-6)); // print ZonedDateTime System.out.println("Before withFixedOffsetZone(): " + zonedDT); // apply withFixedOffsetZone() ZonedDateTime zonedDT2 = zonedDT.withFixedOffsetZone(); // print ZonedDateTime after withFixedOffsetZone() System.out.println("After withFixedOffsetZone(): " + zonedDT2); } } Output: Before withFixedOffsetZone(): 2018-11-04T01:25:43-06:00[US/Central] After withFixedOffsetZone(): 2018-11-04T01:25:43-06:00 Program 2: Java // Java program to demonstrate // ZonedDateTime.withFixedOffsetZone() method import java.time.*; public class GFG { public static void main(String[] args) { // create a ZonedDateTime object ZonedDateTime zonedDT = ZonedDateTime.now(); // print ZonedDateTime System.out.println("Before withFixedOffsetZone(): " + zonedDT); // apply withFixedOffsetZone() ZonedDateTime zonedDT2 = zonedDT.withFixedOffsetZone(); // print ZonedDateTime after withFixedOffsetZone() System.out.println("After withFixedOffsetZone(): " + zonedDT2); } } Output: Before withFixedOffsetZone(): 2018-12-17T05:16:41.417Z[Etc/UTC] After withFixedOffsetZone(): 2018-12-17T05:16:41.417Z Reference: https://docs.oracle.com/javase/10/docs/api/java/time/ZonedDateTime.html#withFixedOffsetZone() Comment More infoAdvertise with us Next Article ZonedDateTime withFixedOffsetZone() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-time package Java-ZonedDateTime Practice Tags : Java Similar Reads ZonedDateTime withSecond() method in Java with Examples withSecond() method of a ZonedDateTime class used to alter second-of-minute in this ZonedDateTime and return a copy of ZonedDateTime after this operation.This method operates on the local time-line, changing the second-of-minute field of the local date-time and after this operation local date-time i 2 min read ZonedDateTime withMinute() method in Java with Examples withMinute() method of a ZonedDateTime class used to alter minute-of-hour in this ZonedDateTime and return a copy of ZonedDateTime after this operation.This method operates on the local time-line, changing the minute-of-hour of the local date-time and after this operation local date-time is converte 2 min read ZonedDateTime withEarlierOffsetAtOverlap() method in Java with Examples The withEarlierOffsetAtOverlap() method of a ZonedDateTime class is used to return a copy of this ZonedDateTime object after changing the zone offset to the earlier of the two valid offsets at a local time-line overlap. The overlap happens when Daylight saving time finishes and one hour is returned 2 min read ZonedDateTime withLaterOffsetAtOverlap() method in Java with Examples The withLaterOffsetAtOverlap() method of a ZonedDateTime class is used to return a copy of this ZonedDateTime 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 t 2 min read ZonedDateTime with() Method in Java with Examples In ZonedDateTime class, there are two types of with() method depending upon the parameters passed to it. with(TemporalAdjuster adjuster) with(TemporalAdjuster adjuster) method of the ZonedDateTime class used to adjusted this date-time and after adjustment returns the copy of adjusted date-time.The a 3 min read Like