Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6973767

number format for Locale Fr seems buggy

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_20"
      Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
      Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      user.language=fr


      A DESCRIPTION OF THE PROBLEM :
      Class sun.text.resources.FormatData_fr
      declares
       { "NumberPatterns",
                      new String[] {
                          "#,##0.###;-#,##0.###", // decimal pattern
                          "#,##0.00 \u00A4;-#,##0.00 \u00A4", // currency pattern
                          "#,##0 %" // percent pattern
                      }
                  },
      and
       { "NumberElements",
                      new String[] {
                          ",", // decimal separator
      ...
      }

      Meaning that according NumberPatterns, a decimal number in french is 12.34 (wrong) but according to NumberElements, is 12,34 (right).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      in a main method:

      DecimalFormatSymbols s = DecimalFormatSymbols.getInstance(new Locale("fr"));
      NumberFormat nf = new DecimalFormat("##.####", s);
      double d = 53.1234567;
      System.err.println(nf.format(d));


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      53,1235
      ACTUAL -
      53.1235

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      manually format

            yhuang Yong Huang (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: