diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-08 19:00:02 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-08 19:00:02 +0000 |
commit | efb35abff3a42d3d9bc3e4e6838576e40b057c2e (patch) | |
tree | 026cb63867f77b3c8c89feae341d8dc461663425 /libjava/java/text/SimpleDateFormat.java | |
parent | f1e69817af215b6e64b2d5d5dc24371d59d547cd (diff) | |
download | ppe42-gcc-efb35abff3a42d3d9bc3e4e6838576e40b057c2e.tar.gz ppe42-gcc-efb35abff3a42d3d9bc3e4e6838576e40b057c2e.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@67633 138bc75d-0d04-0410-961f-82ee72b054a4
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); |