diff options
author | Ito Kazumitsu <kaz@maczuka.gcd.org> | 2007-01-20 03:31:00 +0000 |
---|---|---|
committer | Ito Kazumitsu <kaz@maczuka.gcd.org> | 2007-01-20 03:31:00 +0000 |
commit | c8cf15f0dc77e60e1b3744c6d8a16ec60a26571e (patch) | |
tree | 7e9051ad9629dc8c7a860d1f1c9a885bb0c0f030 /java/text/SimpleDateFormat.java | |
parent | f42e054dd1cc31f00ec9b8247802046122d9b2f3 (diff) | |
download | classpath-c8cf15f0dc77e60e1b3744c6d8a16ec60a26571e.tar.gz |
2007-01-20 Ito Kazumitsu <kaz@maczuka.gcd.org>
* java/text/SimpleDateFormat.java(parse): Corrected the usage of
NumberFormat.
Diffstat (limited to 'java/text/SimpleDateFormat.java')
-rw-r--r-- | java/text/SimpleDateFormat.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/java/text/SimpleDateFormat.java b/java/text/SimpleDateFormat.java index 1e1952569..f78fdcb89 100644 --- a/java/text/SimpleDateFormat.java +++ b/java/text/SimpleDateFormat.java @@ -1101,11 +1101,21 @@ public class SimpleDateFormat extends DateFormat 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; |