Search code examples
javajvmlocale

Locale ES_PE is not rendering number properly


Locale planet specified that the es_PE locale should use "." for decimal and "," for grouping. But when I run this unit test on the Oracle JVM it fails:

public class TestLocale extends TestCase {

   public void test() {
       Locale locale = new Locale("es", "PE");
       DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);

       assertEquals('.', decimalFormatSymbols.getDecimalSeparator());
       assertEquals(',', decimalFormatSymbols.getGroupingSeparator());

   }
}

And it was reported by our support staff that numbers are no rendering correctly on WAS 8 either.

Any idea how to fix this at the JVM level? Do I need to juggle the locale management code in the application for this special case?


Solution

  • Change

    Locale locale = new Locale("es", "PE");
    

    to

    Locale locale = new Locale("es_PE");
    

    By the way, PE is from Peru (where I'm from).