classpath-patches  

[cp-patches] FYI: Fix integer formatting in MessageFormat

Andrew John Hughes
Fri, 02 Jan 2009 04:46:18 -0800

The Mauve test java.text.MessageFormat.format14 demonstrates
that the integer format used by MessageFormat should use the
formatter returned by NumberFormat.getIntegerInstance.  This
is further reinforced by the online specification.  This is probably
a case of our MessageFormat being outdated due to changes in 1.4.
This corrects it.

ChangeLog:

2009-01-02  Andrew John Hughes  <gnu_and...@member.fsf.org>

        * java/text/MessageFormat.java:
        (setLocale(Locale)): Integer format should use
        NumberFormat.getIntegerInstance.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8
Index: java/text/MessageFormat.java
===================================================================
RCS file: /sources/classpath/classpath/java/text/MessageFormat.java,v
retrieving revision 1.29
diff -u -u -r1.29 MessageFormat.java
--- java/text/MessageFormat.java        31 Dec 2008 11:28:12 -0000      1.29
+++ java/text/MessageFormat.java        2 Jan 2009 12:41:31 -0000
@@ -99,12 +99,7 @@
               else if (style.equals("percent"))
                 format = NumberFormat.getPercentInstance(loc);
               else if (style.equals("integer"))
-                {
-                  NumberFormat nf = NumberFormat.getNumberInstance(loc);
-                  nf.setMaximumFractionDigits(0);
-                  nf.setGroupingUsed(false);
-                  format = nf;
-                }
+               format = NumberFormat.getIntegerInstance(loc);
               else
                 {
                   format = NumberFormat.getNumberInstance(loc);
  • [cp-patches] FYI: Fix integer formatting in MessageFormat Andrew John Hughes