diff options
| author | Tom Tromey <tromey@redhat.com> | 2003-06-08 19:00:02 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-06-08 19:00:02 +0000 |
| commit | 0a56537c161e85a9f1410f657c6be20ab0b3f750 (patch) | |
| tree | 026cb63867f77b3c8c89feae341d8dc461663425 /libjava/java/text/SimpleDateFormat.java | |
| parent | 5f158b4400a84d31b7180fbc96b1419264843328 (diff) | |
For PR libgcj/11085:
* java/text/SimpleDateFormat.java (parse(String,ParsePosition)):
Limit number of characters in numeric field when required.
* java/text/DecimalFormat.java (parse(String,ParsePosition)):
Respect maximumIntegerDigits.
From-SVN: r67633
Diffstat (limited to 'libjava/java/text/SimpleDateFormat.java')
| -rw-r--r-- | libjava/java/text/SimpleDateFormat.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java index 06ab66f5a70..7b282f3c62f 100644 --- a/libjava/java/text/SimpleDateFormat.java +++ b/libjava/java/text/SimpleDateFormat.java @@ -570,6 +570,14 @@ public class SimpleDateFormat extends DateFormat while (++fmt_index < fmt_max && pattern.charAt(fmt_index) == ch) ; int fmt_count = fmt_index - first; + + // We might need to limit the number of digits to parse in + // some cases. We look to the next pattern character to + // decide. + boolean limit_digits = false; + if (fmt_index < fmt_max + && standardChars.indexOf(pattern.charAt(fmt_index)) >= 0) + limit_digits = true; --fmt_index; // We can handle most fields automatically: most either are @@ -702,6 +710,8 @@ 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); |
