diff --git a/json/json-core/src/main/scala/io/sphere/json/FromJSON.scala b/json/json-core/src/main/scala/io/sphere/json/FromJSON.scala index 5ce8f3d5..75e1f80d 100644 --- a/json/json-core/src/main/scala/io/sphere/json/FromJSON.scala +++ b/json/json-core/src/main/scala/io/sphere/json/FromJSON.scala @@ -391,8 +391,10 @@ object FromJSON extends FromJSONInstances { .appendPattern("'T'[HH[:mm[:ss]]]") .appendFraction(time.temporal.ChronoField.NANO_OF_SECOND, 0, 9, true) .optionalStart() - .appendOffset("+HHmm", "Z") + .appendOffset("+HH:MM", "Z") .optionalEnd() + .optionalStart() + .appendOffset("+HHmm", "Z") .optionalEnd() .parseDefaulting(time.temporal.ChronoField.MONTH_OF_YEAR, 1L) .parseDefaulting(time.temporal.ChronoField.DAY_OF_MONTH, 1L) diff --git a/json/json-core/src/test/scala/io/sphere/json/DateTimeParsingSpec.scala b/json/json-core/src/test/scala/io/sphere/json/DateTimeParsingSpec.scala index 562e9c3b..06aa68de 100644 --- a/json/json-core/src/test/scala/io/sphere/json/DateTimeParsingSpec.scala +++ b/json/json-core/src/test/scala/io/sphere/json/DateTimeParsingSpec.scala @@ -168,6 +168,22 @@ class DateTimeParsingSpec extends AnyWordSpec with Matchers { Instant.parse("2004-06-09T12:24:48.501Z")) } + "accept a year month day with hour, minute, second, and an offset containing a colon" in { + javaInstantReader.read(JString("2004-06-09T12:24:48+08:00")) shouldBe Valid( + Instant.parse("2004-06-09T04:24:48Z")) + } + "accept a year month day with hour, minute, second, and an offset of zero containing a colon" in { + javaInstantReader.read(JString("2004-06-09T12:24:48+00:00")) shouldBe Valid( + Instant.parse("2004-06-09T12:24:48Z")) + } + "accept a year month day with hour, minute, second, and a negative colon offset" in { + javaInstantReader.read(JString("2004-06-09T12:24:48-08:00")) shouldBe Valid( + Instant.parse("2004-06-09T20:24:48Z")) + } + "accept a year month day with hour, minute, second, and an offset of hours only" in { + javaInstantReader.read(JString("2004-06-09T12:24:48+00")) shouldBe Valid( + Instant.parse("2004-06-09T12:24:48Z")) + } } }