Hi,

With reference to the Comment #3 of the bug 30359,  I suggest the
following patch.

ChangeLog

2007-01-18  Ito Kazumitsu  <[EMAIL PROTECTED]>

        * java/text/SimpleDateFormat(parse): Corrected the usage of
        NumberFormat.

Index: classpath/java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/SimpleDateFormat.java,v
retrieving revision 1.54
diff -u -r1.54 SimpleDateFormat.java
--- classpath/java/text/SimpleDateFormat.java   9 Aug 2006 19:42:22 -0000       
1.54
+++ classpath/java/text/SimpleDateFormat.java   18 Jan 2007 15:43:20 -0000
@@ -1101,11 +1101,21 @@
            if (is_numeric)
              {
                numberFormat.setMinimumIntegerDigits(fmt_count);
-               if (limit_digits)
-                 numberFormat.setMaximumIntegerDigits(fmt_count);
                if (maybe2DigitYear)
                  index = pos.getIndex();
-               Number n = numberFormat.parse(dateStr, pos);
+               Number n = null;
+               if (limit_digits)
+                 {
+                   // numberFormat.setMaximumIntegerDigits(fmt_count) may
+                   // not work as expected. So we explicitly use substring
+                   // of dateStr.
+                   int origPos = pos.getIndex();
+                   pos.setIndex(0);
+                   n = numberFormat.parse(dateStr.substring(origPos, origPos + 
fmt_count), pos);
+                   pos.setIndex(origPos + pos.getIndex());
+                 }
+               else
+                 n = numberFormat.parse(dateStr, pos);
                if (pos == null || ! (n instanceof Long))
                  return null;
                value = n.intValue() + offset;

Reply via email to