Commit 289f9db7 by Michael Koch Committed by Michael Koch

2004-05-30 Michael Koch <konqueror@gmx.de>

	* 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
parent 1b2545bc
2004-05-30 Michael Koch <konqueror@gmx.de> 2004-05-30 Michael Koch <konqueror@gmx.de>
* 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 <konqueror@gmx.de>
* java/nio/Buffer.java * java/nio/Buffer.java
(limit): Fixed off by one error. (limit): Fixed off by one error.
* java/nio/CharBuffer.java * java/nio/CharBuffer.java
......
...@@ -42,13 +42,11 @@ import gnu.java.text.FormatBuffer; ...@@ -42,13 +42,11 @@ import gnu.java.text.FormatBuffer;
import gnu.java.text.FormatCharacterIterator; import gnu.java.text.FormatCharacterIterator;
import gnu.java.text.StringFormatBuffer; import gnu.java.text.StringFormatBuffer;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Currency; import java.util.Currency;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.io.ObjectInputStream;
import java.io.IOException;
/** /**
* @author Tom Tromey <tromey@cygnus.com> * @author Tom Tromey <tromey@cygnus.com>
...@@ -849,7 +847,7 @@ public class DecimalFormat extends NumberFormat ...@@ -849,7 +847,7 @@ public class DecimalFormat extends NumberFormat
// FIXME: handle Inf and NaN. // FIXME: handle Inf and NaN.
// FIXME: do we have to respect minimum digits? // FIXME: do we have to respect minimum digits?
// What about leading zeros? What about multiplier? // What about multiplier?
StringBuffer buf = int_buf; StringBuffer buf = int_buf;
StringBuffer frac_buf = null; StringBuffer frac_buf = null;
...@@ -857,7 +855,13 @@ public class DecimalFormat extends NumberFormat ...@@ -857,7 +855,13 @@ public class DecimalFormat extends NumberFormat
int start_index = index; int start_index = index;
int max = str.length(); int max = str.length();
int exp_index = -1; 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) if (last > 0 && max > last)
max = last; max = last;
......
...@@ -189,6 +189,7 @@ public class SimpleDateFormat extends DateFormat ...@@ -189,6 +189,7 @@ public class SimpleDateFormat extends DateFormat
numberFormat = NumberFormat.getInstance(locale); numberFormat = NumberFormat.getInstance(locale);
numberFormat.setGroupingUsed (false); numberFormat.setGroupingUsed (false);
numberFormat.setParseIntegerOnly (true); numberFormat.setParseIntegerOnly (true);
numberFormat.setMaximumFractionDigits (0);
} }
/** /**
...@@ -216,6 +217,7 @@ public class SimpleDateFormat extends DateFormat ...@@ -216,6 +217,7 @@ public class SimpleDateFormat extends DateFormat
numberFormat = NumberFormat.getInstance(locale); numberFormat = NumberFormat.getInstance(locale);
numberFormat.setGroupingUsed (false); numberFormat.setGroupingUsed (false);
numberFormat.setParseIntegerOnly (true); numberFormat.setParseIntegerOnly (true);
numberFormat.setMaximumFractionDigits (0);
} }
/** /**
...@@ -234,6 +236,7 @@ public class SimpleDateFormat extends DateFormat ...@@ -234,6 +236,7 @@ public class SimpleDateFormat extends DateFormat
numberFormat = NumberFormat.getInstance(); numberFormat = NumberFormat.getInstance();
numberFormat.setGroupingUsed (false); numberFormat.setGroupingUsed (false);
numberFormat.setParseIntegerOnly (true); numberFormat.setParseIntegerOnly (true);
numberFormat.setMaximumFractionDigits (0);
} }
// What is the difference between localized and unlocalized? The // What is the difference between localized and unlocalized? The
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment