diff options
author | Tom Tromey <tromey@redhat.com> | 2003-06-09 16:20:14 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2003-06-09 16:20:14 +0000 |
commit | 8832af513bb0de17a7a0f69e54a4380375d42e22 (patch) | |
tree | 17c8701835392ec46fbc9e82b1083f084396e18f /java/text/SimpleDateFormat.java | |
parent | b663afd19388f93b4402f63e81842a2da4b44874 (diff) | |
download | classpath-8832af513bb0de17a7a0f69e54a4380375d42e22.tar.gz |
* 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.
Diffstat (limited to 'java/text/SimpleDateFormat.java')
-rw-r--r-- | java/text/SimpleDateFormat.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/java/text/SimpleDateFormat.java b/java/text/SimpleDateFormat.java index 06ab66f5a..7b282f3c6 100644 --- a/java/text/SimpleDateFormat.java +++ b/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); |