Reviewers: jat,

Description:
Fix external issue 5062 - DateTimeFormat#formatFractionalSeconds
incorrect for date before 1970 with 0 fractionalSecond


Please review this at http://gwt-code-reviews.appspot.com/715801/show

Affected files:
  M user/src/com/google/gwt/i18n/client/DateTimeFormat.java
  M user/test/com/google/gwt/i18n/client/DateTimeFormat_en_Test.java


Index: user/src/com/google/gwt/i18n/client/DateTimeFormat.java
===================================================================
--- user/src/com/google/gwt/i18n/client/DateTimeFormat.java     (revision 8406)
+++ user/src/com/google/gwt/i18n/client/DateTimeFormat.java     (working copy)
@@ -1254,6 +1254,9 @@
     int value;
     if (time < 0) {
       value = 1000 - (int) (-time % 1000);
+      if (value == 1000) {
+        value = 0;
+      }
     } else {
       value = (int) (time % 1000);
     }
Index: user/test/com/google/gwt/i18n/client/DateTimeFormat_en_Test.java
===================================================================
--- user/test/com/google/gwt/i18n/client/DateTimeFormat_en_Test.java (revision 8406) +++ user/test/com/google/gwt/i18n/client/DateTimeFormat_en_Test.java (working copy)
@@ -542,6 +542,9 @@
     assertEquals("055", DateTimeFormat.getFormat("SSS").format(date, utc));
     assertEquals("06", DateTimeFormat.getFormat("SS").format(date, utc));
     assertEquals("1", DateTimeFormat.getFormat("S").format(date, utc));
+
+    date = new Date(midnight);
+    assertEquals("000", DateTimeFormat.getFormat("SSS").format(date, utc));
   }

   public void testZeroPadYear() {


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to