I found one strange situation in Java 8. I am going to format the number to a specific locale, and some of them work incorrectly.
long tenMillion = 10000000L;
Locale[] locales = Locale.getAvailableLocales();
for (Locale locale : locales) {
String currency = "Ten million in " + locale.getDisplayName() + " is " +
NumberFormat.getCurrencyInstance(locale).format(tenMillion);
if (locale.getDisplayName().equals("Ukrainian")){
System.out.println(currency);
System.out.println(Currency.getInstance("UAH").getSymbol(locale));
}
}
Exit
Ten million in Ukrainian is ¤ 10 000 000,00
UAH
But when I create an instance of this location, I have the correct results:
Locale uaLoc = new Locale("uk", "UA");
String currency = "Ten million in " + uaLoc.getDisplayName() + " is " +
NumberFormat.getCurrencyInstance(uaLoc).format(tenMillion);
System.out.println(currency);
System.out.println(Currency.getInstance("UAH").getSymbol(uaLoc));
Exit
Ten million in Ukrainian (Ukraine) is 10 000 000 .
.
This is true not only for the Ukrainian language and for others:
Ten million in Bulgarian is ¤ 10 000 000,00
Ten million in Italian is ¤ 10.000.000,00
Ten million in Korean is ¤ 10,000,000.00
Ten million in Latvian is ¤ 10 000 000,00
etc.
But locales with countries are formatted correctly:
Ten million in Bulgarian (Bulgaria) is .10 000 000
Ten million in Italian (Italy) is € 10.000.000,00
Ten million in Italian (Switzerland) is SFr. 10'000'000.00
Ten million in Korean (South Korea) is ₩10,000,000
Ten million in Latvian (Latvia) is 10 000 000 €
It seems that the currency is only associated with the country. And this is a very correct way!
Does anyone know how to request API changes for Java 9? It would be great to follow the API
Locale.getAvailableCountryLocales();
to avoid misunderstandings.
thanks