diff --git a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java index 5cf82ab0..c4545a61 100644 --- a/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java +++ b/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserializer.java @@ -18,9 +18,7 @@ import java.io.IOException; import java.time.DateTimeException; -import java.time.Instant; import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import com.fasterxml.jackson.annotation.JsonFormat; @@ -150,15 +148,6 @@ protected LocalDateTime _fromString(JsonParser p, DeserializationContext ctxt, } final DateTimeFormatter format = _formatter; try { - if (format == DEFAULT_FORMATTER) { - // JavaScript by default includes time and zone in JSON serialized Dates (UTC/ISO instant format). - if (string.length() > 10 && string.charAt(10) == 'T') { - if (string.endsWith("Z")) { - return LocalDateTime.ofInstant(Instant.parse(string), ZoneOffset.UTC); - } - return LocalDateTime.parse(string, DEFAULT_FORMATTER); - } - } return LocalDateTime.parse(string, format); } catch (DateTimeException e) { return _handleDateTimeFormatException(ctxt, e, format, string); diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java index 326c894a..a951a6af 100644 --- a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/deser/LocalDateTimeDeserTest.java @@ -20,7 +20,6 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.Month; -import java.time.ZoneOffset; import java.time.format.DateTimeParseException; import java.time.temporal.Temporal; import java.util.Calendar; @@ -169,11 +168,16 @@ public void testDeserializationAsString03() throws Exception } @Test - public void testDeserializationAsString04() throws Exception + public void testBadDeserializationOfTimeWithTimeZone() throws Exception { - Instant instant = Instant.now(); - LocalDateTime value = MAPPER.readValue('"' + instant.toString() + '"', LocalDateTime.class); - assertEquals("The value is not correct.", LocalDateTime.ofInstant(instant, ZoneOffset.UTC), value); + try { + Instant instant = Instant.now(); + MAPPER.readValue('"' + instant.toString() + '"', LocalDateTime.class); + fail("expected fail"); + } catch (InvalidFormatException e) { + verifyException(e, "Cannot deserialize value of type"); + verifyException(e, "from String \""); + } } @Test