Close

Java Date Time - ZonedDateTime.withFixedOffsetZone() Examples

Java Date Time Java Java API 


Class:

java.time.ZonedDateTime

java.lang.Objectjava.lang.Objectjava.time.ZonedDateTimejava.time.ZonedDateTimejava.time.temporal.TemporalTemporaljava.time.chrono.ChronoZonedDateTimeChronoZonedDateTimejava.io.SerializableSerializableLogicBig

Method:

public ZonedDateTime withFixedOffsetZone()

Returns a copy of this ZonedDateTime with the zone ID set to the offset. This returns a zoned date-time where the zone ID is the same as getOffset(). That means, with the returned instance, all region-based complex rules are not applicable anymore.

Examples


package com.logicbig.example.zoneddatetime;

import java.time.ZonedDateTime;

public class WithFixedOffsetZoneExample {

public static void main(String... args) {
ZonedDateTime d = ZonedDateTime.now();
System.out.println(d);

ZonedDateTime d2 = d.withFixedOffsetZone();
System.out.println(d2);
}
}

Output

2017-05-01T16:00:13.645-05:00[America/Chicago]
2017-05-01T16:00:13.645-05:00




See Also