aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/text/SimpleDateFormat.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java/text/SimpleDateFormat.java')
-rw-r--r--libjava/classpath/java/text/SimpleDateFormat.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java
index 1e19525..f78fdcb 100644
--- a/libjava/classpath/java/text/SimpleDateFormat.java
+++ b/libjava/classpath/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;