Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!