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

Localized monetary symbols are not reflected in `toLocalizedPattern` return value

XMLWordPrintable

    • b21
    • 13
    • b14
    • generic
    • generic
    • Verified

        A DESCRIPTION OF THE PROBLEM :
        NumberFormat.getCurrencyInstance().format(x) use the wrong decimal point for locale fr_CH. The localized pattern show that it have the right decimal point but it does not use for formatting. Instead of the expected comma there is a point.

        REGRESSION : Last worked in version 11

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Java Version: 11.0.11+9
        Currency: -1 234,12 CHF with pattern: # ##0,00' '¤
        Number: -1 234,125 with pattern: # ##0,###
        ACTUAL -
        Java Version: 17.0.2+8-LTS-86
        Currency: -1 234.12 CHF with pattern: # ##0,00 ¤
        Number: -1 234,125 with pattern: # ##0,###

        ---------- BEGIN SOURCE ----------

        import java.text.DecimalFormat;
        import java.text.NumberFormat;
        import java.util.Locale;

        public class CurrencyFormatTest {
            public static void main( String[] args ) {
                System.err.println( "Java Version: " + System.getProperty( "java.vm.version" ) );
                Locale locale = new Locale( "fr", "CH" );
                NumberFormat javaFormat = NumberFormat.getCurrencyInstance( locale );
                String str = javaFormat.format( -1234.125 );
                System.err.println( "Currency: " + str + " with pattern: " + ((DecimalFormat)javaFormat).toLocalizedPattern());

                javaFormat = NumberFormat.getNumberInstance( locale );
                str = javaFormat.format( -1234.125 );
                System.err.println( "Number: " + str + " with pattern: " + ((DecimalFormat)javaFormat).toLocalizedPattern());
            }
        }

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

        FREQUENCY : always


              naoto Naoto Sato
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Created:
                Updated:
                Resolved: