From 289f9db7db45a044bfc59831b56e25cb4aa2e7c8 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Sun, 30 May 2004 13:42:24 +0000 Subject: [PATCH] 2004-05-30 Michael Koch * java/text/DecimalFormat.java (parse): Fixed parsing of decimal strings. Number of maximum digits to be read should now work. * java/text/SimpleDateFormat.java (SimpleDateFormat): Set maximumFractionDigit to 0 for the number formatter. This fixes DateFormatTest. From-SVN: r82449 --- libjava/ChangeLog | 9 +++++++++ libjava/java/text/DecimalFormat.java | 16 ++++++++++------ libjava/java/text/SimpleDateFormat.java | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index b567876a63a..12498406a09 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,12 @@ +2004-05-30 Michael Koch + + * java/text/DecimalFormat.java + (parse): Fixed parsing of decimal strings. Number of maximum + digits to be read should now work. + * java/text/SimpleDateFormat.java + (SimpleDateFormat): Set maximumFractionDigit to 0 for the number + formatter. This fixes DateFormatTest. + 2004-05-30 Michael Koch * java/nio/Buffer.java diff --git a/libjava/java/text/DecimalFormat.java b/libjava/java/text/DecimalFormat.java index 497a705670c..eda4d043740 100644 --- a/libjava/java/text/DecimalFormat.java +++ b/libjava/java/text/DecimalFormat.java @@ -42,13 +42,11 @@ import gnu.java.text.FormatBuffer; import gnu.java.text.FormatCharacterIterator; import gnu.java.text.StringFormatBuffer; +import java.io.IOException; +import java.io.ObjectInputStream; import java.util.Currency; import java.util.HashMap; import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.io.ObjectInputStream; -import java.io.IOException; /** * @author Tom Tromey @@ -849,7 +847,7 @@ public class DecimalFormat extends NumberFormat // FIXME: handle Inf and NaN. // FIXME: do we have to respect minimum digits? - // What about leading zeros? What about multiplier? + // What about multiplier? StringBuffer buf = int_buf; StringBuffer frac_buf = null; @@ -857,7 +855,13 @@ public class DecimalFormat extends NumberFormat int start_index = index; int max = str.length(); int exp_index = -1; - int last = index + MAXIMUM_INTEGER_DIGITS; + int last = index + maximumIntegerDigits; + + if (maximumFractionDigits > 0) + last += maximumFractionDigits + 1; + + if (useExponentialNotation) + last += minExponentDigits + 1; if (last > 0 && max > last) max = last; diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java index 5f3614eefcf..ea3e09fab46 100644 --- a/libjava/java/text/SimpleDateFormat.java +++ b/libjava/java/text/SimpleDateFormat.java @@ -189,6 +189,7 @@ public class SimpleDateFormat extends DateFormat numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); + numberFormat.setMaximumFractionDigits (0); } /** @@ -216,6 +217,7 @@ public class SimpleDateFormat extends DateFormat numberFormat = NumberFormat.getInstance(locale); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); + numberFormat.setMaximumFractionDigits (0); } /** @@ -234,6 +236,7 @@ public class SimpleDateFormat extends DateFormat numberFormat = NumberFormat.getInstance(); numberFormat.setGroupingUsed (false); numberFormat.setParseIntegerOnly (true); + numberFormat.setMaximumFractionDigits (0); } // What is the difference between localized and unlocalized? The -- 2.30.2