@@ -61,12 +61,25 @@ public class InstantDeserializer<T extends Temporal>
6161 = JavaTimeFeature .ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS .enabledByDefault ();
6262
6363 /**
64- * Constants used to check if ISO 8601 time string is colonless . See [jackson-modules-java8#131]
64+ * Constants used to check if ISO 8601 time string is colon-less . See [jackson-modules-java8#131]
6565 *
6666 * @since 2.13
6767 */
6868 protected static final Pattern ISO8601_COLONLESS_OFFSET_REGEX = Pattern .compile ("[+-][0-9]{4}(?=\\ [|$)" );
6969
70+ // @since 2.18.2
71+ private static OffsetDateTime decimalToOffsetDateTime (FromDecimalArguments args ) {
72+ // [jackson-modules-java8#308] Since 2.18.2 : Fix can't deserialize OffsetDateTime.MIN: Invalid value for EpochDay
73+ if (args .integer == OffsetDateTime .MIN .toEpochSecond () && args .fraction == OffsetDateTime .MIN .getNano ()) {
74+ return OffsetDateTime .ofInstant (Instant .ofEpochSecond (OffsetDateTime .MIN .toEpochSecond (), OffsetDateTime .MIN .getNano ()), OffsetDateTime .MIN .getOffset ());
75+ }
76+ // [jackson-modules-java8#308] Since 2.18.2 : For OffsetDateTime.MAX case
77+ if (args .integer == OffsetDateTime .MAX .toEpochSecond () && args .fraction == OffsetDateTime .MAX .getNano ()) {
78+ return OffsetDateTime .ofInstant (Instant .ofEpochSecond (OffsetDateTime .MAX .toEpochSecond (), OffsetDateTime .MAX .getNano ()), OffsetDateTime .MAX .getOffset ());
79+ }
80+ return OffsetDateTime .ofInstant (Instant .ofEpochSecond (args .integer , args .fraction ), args .zoneId );
81+ }
82+
7083 public static final InstantDeserializer <Instant > INSTANT = new InstantDeserializer <>(
7184 Instant .class , DateTimeFormatter .ISO_INSTANT ,
7285 Instant ::from ,
@@ -82,7 +95,7 @@ public class InstantDeserializer<T extends Temporal>
8295 OffsetDateTime .class , DateTimeFormatter .ISO_OFFSET_DATE_TIME ,
8396 OffsetDateTime ::from ,
8497 a -> OffsetDateTime .ofInstant (Instant .ofEpochMilli (a .value ), a .zoneId ),
85- a -> OffsetDateTime . ofInstant ( Instant . ofEpochSecond ( a . integer , a . fraction ), a . zoneId ) ,
98+ InstantDeserializer :: decimalToOffsetDateTime ,
8699 (d , z ) -> (d .isEqual (OffsetDateTime .MIN ) || d .isEqual (OffsetDateTime .MAX ) ? d : d .withOffsetSameInstant (z .getRules ().getOffset (d .toLocalDateTime ()))),
87100 true , // yes, replace zero offset with Z
88101 DEFAULT_NORMALIZE_ZONE_ID ,
0 commit comments