Update ISO-8601 format to accept a timezone of a literal "Z" to mean
GMT+0.
Review by: mtnguyen@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10773 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/shared/DateTimeFormat.java b/user/src/com/google/gwt/i18n/shared/DateTimeFormat.java
index 6cfb72f..7996850 100644
--- a/user/src/com/google/gwt/i18n/shared/DateTimeFormat.java
+++ b/user/src/com/google/gwt/i18n/shared/DateTimeFormat.java
@@ -1896,8 +1896,15 @@
cal.setSeconds(value);
return true;
- case 'z': // time zone offset
case 'Z': // time zone RFC
+ // ISO-8601 times can have a literal Z to indicate GMT+0
+ if (start < text.length() && text.charAt(start) == 'Z') {
+ pos[0]++;
+ cal.setTzOffset(0);
+ return true;
+ }
+ // $FALL-THROUGH$
+ case 'z': // time zone offset
case 'v': // time zone generic
return subParseTimeZoneInGMT(text, start, pos, cal);
default:
diff --git a/user/test/com/google/gwt/i18n/shared/DateTimeFormatTestBase.java b/user/test/com/google/gwt/i18n/shared/DateTimeFormatTestBase.java
index dcdffaa..405d52b 100644
--- a/user/test/com/google/gwt/i18n/shared/DateTimeFormatTestBase.java
+++ b/user/test/com/google/gwt/i18n/shared/DateTimeFormatTestBase.java
@@ -69,6 +69,10 @@
Date date = new Date(Date.UTC(2006 - 1900, 6, 27, 13, 10, 10));
String str = dtf.format(date, TEST_TIMEZONE);
assertEquals("2006-07-27T08:10:10.000-05:00", str);
+
+ date = dtf.parse("2006-07-27T13:10:10.000Z");
+ str = dtf.format(date, TEST_TIMEZONE);
+ assertEquals("2006-07-27T08:10:10.000-05:00", str);
}
@SuppressWarnings("deprecation")