Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
Idiomatic way to remove country code from currency format?

Somewhere between Java 11 and 17 currency formatting changed to where this:

NumberFormat.getCurrencyInstance(Locale.CANADA_FRENCH).format(100.00)

would print 100,00 $ CA instead of 100,00 $.

Is there a better way than this to remove the country code CA?

var currencyFormat = NumberFormat.getCurrencyInstance(Locale.CANADA_FRENCH);
if (currencyFormat instanceof DecimalFormat decimalFormat) {
    var symbols = DecimalFormatSymbols.getInstance(Locale.CANADA_FRENCH);
    symbols.setCurrencySymbol("$");
    decimalFormat.setDecimalFormatSymbols(symbols);
}

Seems a bit much just to get back something that was the default behavior up until recently.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I dug a bit into this, the JDK locale data comes from Unicode CLDR by default, and it seems they reverted from $ CA to $ back in August, see CLDR-14862 and this commit (expand common/main/fr_CA.xml and then go to lines 5914/5923).

This was part of v40, released in October, so too late for JDK 17 whose doc says it uses CLDR v35.1 (which was introduced in Java 13) but it seems it was updated to v39 in April 2021 and they forgot the release note (JDK 16 appears to have been upgraded to v38 already).

CLDR v40 is planned for JDK 19.

You may want to run your application using the COMPAT locales first, with

-Djava.locale.providers=COMPAT,CLDR,SPI

(found here but see also LocaleServiceProvider)

This will use the locales compatible with Java 8, where this issue is not present.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda