From e9fa04296f45f1a40937f4bdfcd352f2d6ae999a Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 4 Jun 2015 21:58:09 -0700 Subject: [PATCH] Update release notes for #816 --- release-notes/CREDITS | 4 ++++ release-notes/VERSION | 2 ++ .../jackson/databind/util/ISO8601Utils.java | 6 +++-- .../databind/util/ISO8601UtilsTest.java | 24 ------------------- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/release-notes/CREDITS b/release-notes/CREDITS index 0dc5c9d44d..56b654dbab 100644 --- a/release-notes/CREDITS +++ b/release-notes/CREDITS @@ -250,6 +250,10 @@ Charles Allen: `Thread.currentThread().getContextClassLoader()` (2.5.4) +Andrew Goodale (newyankeecodeshop@github) + * Contributed #816: Allow date-only ISO strings to have no time zone + (2.5.4) + Kamil BenedykciƄski (Kamil-Benedykcinski@github) * Contributed #801: Using `@JsonCreator` cause generating invalid path reference in `JsonMappingException` diff --git a/release-notes/VERSION b/release-notes/VERSION index 3ba9f9ef26..382e2be2bf 100644 --- a/release-notes/VERSION +++ b/release-notes/VERSION @@ -21,6 +21,8 @@ Project: jackson-databind #801: Using `@JsonCreator` cause generating invalid path reference in `JsonMappingException` (contributed by Kamil B) #815: Presence of PropertyNamingStrategy Makes Deserialization fail +#816: Allow date-only ISO strings to have no time zone + (contributed by Andrew G) - Fix handling of Enums wrt JSON Schema, when 'toString()' used for serialization 2.5.3 (24-Apr-2015) diff --git a/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java b/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java index 24477ea964..725b32a116 100644 --- a/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java +++ b/src/main/java/com/fasterxml/jackson/databind/util/ISO8601Utils.java @@ -154,14 +154,16 @@ public static Date parse(String date, ParsePosition pos) throws ParseException { int milliseconds = 0; // always use 0 otherwise returned date will include millis of current time // if the value has no time component (and no time zone), we are done - if (!checkOffset(date, offset, 'T') && (date.length() <= offset)) { + boolean hasT = checkOffset(date, offset, 'T'); + + if (!hasT && (date.length() <= offset)) { Calendar calendar = new GregorianCalendar(year, month - 1, day); pos.setIndex(offset); return calendar.getTime(); } - if (checkOffset(date, offset, 'T')) { + if (hasT) { // extract hours, minutes, seconds and milliseconds hour = parseInt(date, offset += 1, offset += 2); diff --git a/src/test/java/com/fasterxml/jackson/databind/util/ISO8601UtilsTest.java b/src/test/java/com/fasterxml/jackson/databind/util/ISO8601UtilsTest.java index 9c97807fcf..8df2681308 100644 --- a/src/test/java/com/fasterxml/jackson/databind/util/ISO8601UtilsTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/util/ISO8601UtilsTest.java @@ -116,30 +116,6 @@ public void testParseWithoutTime() throws ParseException { assertEquals(dateWithoutTime, d); } - public void testParseWithoutTimeAndTimeZoneMustFail() { - try { - ISO8601Utils.parse("2007-08-13", new ParsePosition(0)); - fail(); - } catch (ParseException p) { - } - try { - ISO8601Utils.parse("20070813", new ParsePosition(0)); - fail(); - } catch (ParseException p) { - } - try { - ISO8601Utils.parse("2007-08-13", new ParsePosition(0)); - fail(); - } catch (ParseException p) { - } - try { - ISO8601Utils.parse("20070813", new ParsePosition(0)); - fail(); - } catch (ParseException p) { - } - } - - public void testParseOptional() throws java.text.ParseException { Date d = ISO8601Utils.parse("2007-08-13T19:51Z", new ParsePosition(0)); assertEquals(dateZeroSecondAndMillis, d);