From 978a76218c7fb96c6614948ffed306aedd6ee35c Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Thu, 17 Jan 2013 14:12:12 -0800 Subject: [PATCH] Fixes to parsing of due times --- api/src/com/todoroo/andlib/utility/DateUtilities.java | 9 ++++++--- .../actfm/sync/messages/JSONChangeToPropertyVisitor.java | 3 +-- .../com/todoroo/andlib/utility/DateUtilitiesTest.java | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/src/com/todoroo/andlib/utility/DateUtilities.java b/api/src/com/todoroo/andlib/utility/DateUtilities.java index 82edb84b8..78831994a 100644 --- a/api/src/com/todoroo/andlib/utility/DateUtilities.java +++ b/api/src/com/todoroo/andlib/utility/DateUtilities.java @@ -268,16 +268,19 @@ public class DateUtilities { return date.getTime(); } + public static boolean isoStringHasTime(String iso8601String) { + return iso8601String.length() > 12; + } + public static Date parseIso8601(String iso8601String) throws ParseException { String formatString; - if (iso8601String.endsWith("Z")) { //$NON-NLS-1$ - // Time exists + if (isoStringHasTime(iso8601String)) { // Time exists iso8601String = iso8601String.replace("Z", "+00:00"); //$NON-NLS-1$ //$NON-NLS-2$ try { iso8601String = iso8601String.substring(0, 22) + iso8601String.substring(23); } catch (IndexOutOfBoundsException e) { e.printStackTrace(); - throw new ParseException("Invalid ISO 8601 length", 0); //$NON-NLS-1$ + throw new ParseException("Invalid ISO 8601 length for string " + iso8601String, 0); //$NON-NLS-1$ } formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$ } else { diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/JSONChangeToPropertyVisitor.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/JSONChangeToPropertyVisitor.java index 246ec4161..e2f7cd646 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/JSONChangeToPropertyVisitor.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/JSONChangeToPropertyVisitor.java @@ -52,8 +52,7 @@ public class JSONChangeToPropertyVisitor implements PropertyVisitor