@@ -54,13 +54,6 @@ public class InstantDeserializer<T extends Temporal>
54
54
{
55
55
private static final long serialVersionUID = 1L ;
56
56
57
- /**
58
- * Constants used to check if the time offset is zero. See [jackson-modules-java8#18]
59
- *
60
- * @since 2.9.0
61
- */
62
- private static final Pattern ISO8601_UTC_ZERO_OFFSET_SUFFIX_REGEX = Pattern .compile ("\\ +00:?(00)?$" );
63
-
64
57
/**
65
58
* Constants used to check if ISO 8601 time string is colonless. See [jackson-modules-java8#131]
66
59
*
@@ -226,7 +219,7 @@ public T deserialize(JsonParser parser, DeserializationContext context) throws I
226
219
return (T ) parser .getEmbeddedObject ();
227
220
228
221
case JsonTokenId .ID_START_ARRAY :
229
- return _deserializeFromArray (parser , context );
222
+ return _deserializeFromArray (parser , context );
230
223
}
231
224
return _handleUnexpectedToken (context , parser , JsonToken .VALUE_STRING ,
232
225
JsonToken .VALUE_NUMBER_INT , JsonToken .VALUE_NUMBER_FLOAT );
@@ -337,12 +330,31 @@ private ZoneId getZone(DeserializationContext context)
337
330
private String replaceZeroOffsetAsZIfNecessary (String text )
338
331
{
339
332
if (replaceZeroOffsetAsZ ) {
340
- return ISO8601_UTC_ZERO_OFFSET_SUFFIX_REGEX . matcher (text ). replaceFirst ( "Z" );
333
+ return replaceZeroOffsetAsZ (text );
341
334
}
342
335
343
336
return text ;
344
337
}
345
338
339
+ private static String replaceZeroOffsetAsZ (String text )
340
+ {
341
+ int plusIndex = text .lastIndexOf ('+' );
342
+ if (plusIndex < 0 ) {
343
+ return text ;
344
+ }
345
+ int maybeOffsetIndex = plusIndex + 1 ;
346
+ int remaining = text .length () - maybeOffsetIndex ;
347
+ if (remaining < 2 || remaining == 3 || remaining > 5 ) {
348
+ return text ;
349
+ }
350
+
351
+ String maybeOffset = text .substring (maybeOffsetIndex );
352
+ if ("00" .equals (maybeOffset ) || "0000" .equals (maybeOffset ) || "00:00" .equals (maybeOffset )) {
353
+ return text .substring (0 , plusIndex ) + 'Z' ;
354
+ }
355
+ return text ;
356
+ }
357
+
346
358
// @since 2.13
347
359
private String addInColonToOffsetIfMissing (String text )
348
360
{
0 commit comments