This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: java.text - date parsing fixes


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I just commited the attached patch from GNU classpath to merge these 
clases again.

2004-05-30  Guilhem Lavaux <guilhem@kaffe.org>

	* 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.


- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAueUwWSOgCCdjSDsRAr40AJ4v/+0B5TxOkxwiHA6U1na0eTVvbACcCBbn
9bnPFDN4D6Th8Ex7wKTt0/o=
=R2r+
-----END PGP SIGNATURE-----
Index: java/text/DecimalFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/DecimalFormat.java,v
retrieving revision 1.17
diff -u -b -B -r1.17 DecimalFormat.java
--- java/text/DecimalFormat.java	5 May 2004 06:02:37 -0000	1.17
+++ java/text/DecimalFormat.java	30 May 2004 13:42:03 -0000
@@ -42,13 +42,11 @@
 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 <tromey@cygnus.com>
@@ -849,7 +847,7 @@
     // 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 @@
     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;
Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/SimpleDateFormat.java,v
retrieving revision 1.27
diff -u -b -B -r1.27 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java	4 May 2004 22:14:12 -0000	1.27
+++ java/text/SimpleDateFormat.java	30 May 2004 13:42:03 -0000
@@ -189,6 +189,7 @@
     numberFormat = NumberFormat.getInstance(locale);
     numberFormat.setGroupingUsed (false);
     numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
   }
   
   /**
@@ -216,6 +217,7 @@
     numberFormat = NumberFormat.getInstance(locale);
     numberFormat.setGroupingUsed (false);
     numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
   }
 
   /**
@@ -234,6 +236,7 @@
     numberFormat = NumberFormat.getInstance();
     numberFormat.setGroupingUsed (false);
     numberFormat.setParseIntegerOnly (true);
+    numberFormat.setMaximumFractionDigits (0);
   }
 
   // What is the difference between localized and unlocalized?  The

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]