Reviewers: jat,
Description:
From external GWT issue 4216:
-----
System.out.println(DateTimeFormat.getFormat("SS").format(new
Date(-631151998945))) displays "0-93" instead of the expected "05" or
"06".
That time is 1.055 seconds after midnight January 1, 1950.
-----
Please review this at http://gwt-code-reviews.appspot.com/100814
Affected files:
user/src/com/google/gwt/i18n/client/DateTimeFormat.java
Index: user/src/com/google/gwt/i18n/client/DateTimeFormat.java
===================================================================
--- user/src/com/google/gwt/i18n/client/DateTimeFormat.java (revision 6905)
+++ user/src/com/google/gwt/i18n/client/DateTimeFormat.java (working copy)
@@ -989,7 +989,13 @@
// Fractional seconds should be left-justified, ie. zero must be padded
// from left. For example, if value in milliseconds is 5, and count is
3,
// the output need to be "005".
- int value = (int) (date.getTime() % 1000);
+ long time = date.getTime();
+ int value;
+ if (time < 0) {
+ value = 1000 - (int) (-time % 1000);
+ } else {
+ value = (int) (time % 1000);
+ }
if (count == 1) {
value = (value + 50) / 100; // Round to 100ms.
buf.append(Integer.toString(value));
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors