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

DecimalFormatSymbols has wrong grouping Separator for Hungarian (hu) Language

XMLWordPrintable

      FULL PRODUCT VERSION :
      C:\>java -version
      java version "1.5.0_12"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
      Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      DecimalFormatSymbols has wrong grouping Separator for Hungarian (hu) Language.

      When using DecimalFormat to Format a Currency value, or a Number, the Grouping Separator shows up as a space ' ' instead of a period '.'

      This is incorrect.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       public static void main(String[] args)
        {
          Locale locale = new Locale("hu", "HU");
          NumberFormat df = NumberFormat.getCurrencyInstance(locale);
          BigDecimal bd = new BigDecimal("12345678.90");
          System.out.println("value: " + df.format(bd));
        }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      value: Ft12.345.678,9

      ACTUAL -
      value: Ft12 345 678,9


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
       public static void main(String[] args)
        {
          Locale locale = new Locale("hu", "HU");
          NumberFormat df = NumberFormat.getCurrencyInstance(locale);
          BigDecimal bd = new BigDecimal("12345678.90");
          System.out.println("value: " + df.format(bd));
        }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
        public static void main(String[] args)
        {
          Locale locale = new Locale("hu", "HU");
          DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance(locale);
          BigDecimal bd = new BigDecimal("12345678.90");
          
      // Manually change the grouping separator after you get the Formatter.
          DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
          dfs.setGroupingSeparator('.');
          df.setDecimalFormatSymbols(dfs);
          
          System.out.println("value: " + df.format(bd));
        }

            jtusla Jiri Tusla (Inactive)
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: