2121import com .fasterxml .jackson .core .JsonToken ;
2222import com .fasterxml .jackson .core .JsonTokenId ;
2323import com .fasterxml .jackson .core .io .NumberInput ;
24+ import com .fasterxml .jackson .core .util .JacksonFeatureSet ;
2425import com .fasterxml .jackson .databind .BeanProperty ;
2526import com .fasterxml .jackson .databind .DeserializationContext ;
2627import com .fasterxml .jackson .databind .DeserializationFeature ;
2728import com .fasterxml .jackson .datatype .jsr310 .DecimalUtils ;
29+ import com .fasterxml .jackson .datatype .jsr310 .JavaTimeFeature ;
2830
2931import java .io .IOException ;
3032import java .math .BigDecimal ;
@@ -54,6 +56,8 @@ public class InstantDeserializer<T extends Temporal>
5456{
5557 private static final long serialVersionUID = 1L ;
5658
59+ private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature .NORMALIZE_DESERIALIZED_ZONE_ID .enabledByDefault ();
60+
5761 /**
5862 * Constants used to check if ISO 8601 time string is colonless. See [jackson-modules-java8#131]
5963 *
@@ -68,7 +72,7 @@ public class InstantDeserializer<T extends Temporal>
6872 a -> Instant .ofEpochSecond (a .integer , a .fraction ),
6973 null ,
7074 true , // yes, replace zero offset with Z
71- true // default: yes, normalize ZoneId
75+ DEFAULT_NORMALIZE_ZONE_ID
7276 );
7377
7478 public static final InstantDeserializer <OffsetDateTime > OFFSET_DATE_TIME = new InstantDeserializer <>(
@@ -78,7 +82,7 @@ public class InstantDeserializer<T extends Temporal>
7882 a -> OffsetDateTime .ofInstant (Instant .ofEpochSecond (a .integer , a .fraction ), a .zoneId ),
7983 (d , z ) -> (d .isEqual (OffsetDateTime .MIN ) || d .isEqual (OffsetDateTime .MAX ) ? d : d .withOffsetSameInstant (z .getRules ().getOffset (d .toLocalDateTime ()))),
8084 true , // yes, replace zero offset with Z
81- true // default: yes, normalize ZoneId
85+ DEFAULT_NORMALIZE_ZONE_ID
8286 );
8387
8488 public static final InstantDeserializer <ZonedDateTime > ZONED_DATE_TIME = new InstantDeserializer <>(
@@ -88,7 +92,7 @@ public class InstantDeserializer<T extends Temporal>
8892 a -> ZonedDateTime .ofInstant (Instant .ofEpochSecond (a .integer , a .fraction ), a .zoneId ),
8993 ZonedDateTime ::withZoneSameInstant ,
9094 false , // keep zero offset and Z separate since zones explicitly supported
91- true // default: yes, normalize ZoneId
95+ DEFAULT_NORMALIZE_ZONE_ID
9296 );
9397
9498 protected final Function <FromIntegerArguments , T > fromMilliseconds ;
@@ -212,6 +216,26 @@ protected InstantDeserializer(InstantDeserializer<T> base,
212216 _normalizeZoneId = base ._normalizeZoneId ;
213217 }
214218
219+ /**
220+ * @since 2.16
221+ */
222+ @ SuppressWarnings ("unchecked" )
223+ protected InstantDeserializer (InstantDeserializer <T > base ,
224+ JacksonFeatureSet <JavaTimeFeature > features )
225+ {
226+ super ((Class <T >) base .handledType (), base ._formatter );
227+ parsedToValue = base .parsedToValue ;
228+ fromMilliseconds = base .fromMilliseconds ;
229+ fromNanoseconds = base .fromNanoseconds ;
230+ adjust = base .adjust ;
231+ replaceZeroOffsetAsZ = base .replaceZeroOffsetAsZ ;
232+ _adjustToContextTZOverride = base ._adjustToContextTZOverride ;
233+ _readTimestampsAsNanosOverride = base ._readTimestampsAsNanosOverride ;
234+
235+ _normalizeZoneId = features .isEnabled (JavaTimeFeature .NORMALIZE_DESERIALIZED_ZONE_ID );
236+
237+ }
238+
215239 @ Override
216240 protected InstantDeserializer <T > withDateFormat (DateTimeFormatter dtf ) {
217241 if (dtf == _formatter ) {
@@ -225,6 +249,14 @@ protected InstantDeserializer<T> withLeniency(Boolean leniency) {
225249 return new InstantDeserializer <>(this , _formatter , leniency );
226250 }
227251
252+ // @since 2.16
253+ public InstantDeserializer <T > withFeatures (JacksonFeatureSet <JavaTimeFeature > features ) {
254+ if (_normalizeZoneId == features .isEnabled (JavaTimeFeature .NORMALIZE_DESERIALIZED_ZONE_ID )) {
255+ return this ;
256+ }
257+ return new InstantDeserializer <>(this , features );
258+ }
259+
228260 @ SuppressWarnings ("unchecked" )
229261 @ Override // @since 2.12.1
230262 protected JSR310DateTimeDeserializerBase <?> _withFormatOverrides (DeserializationContext ctxt ,
0 commit comments