From efb35abff3a42d3d9bc3e4e6838576e40b057c2e Mon Sep 17 00:00:00 2001 From: tromey Date: Sun, 8 Jun 2003 19:00:02 +0000 Subject: 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 --- libjava/java/text/SimpleDateFormat.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libjava/java/text/SimpleDateFormat.java') 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); -- cgit v1.2.1