Reputation: 3939
Locale locale = Locale.getDefault();
final NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
Locale is es_US
numberFormat is
java.text.DecimalFormatSymbols[currency=USD,currencySymbol=$,decimalSeparator=,,digit=#,exponentSeparator=E,groupingSeparator=.,infinity=∞,intlCurrencySymbol=USD,minusSign=-,monetarySeparator=,,NaN=NaN,patternSeparator=;,perMill=‰,percent=%,zeroDigit=0]
The decimalSeparator and groupingSeparator are wrong, they should be . and , respectively. Is this a bug in Android?
EDIT:
DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) numberFormat).getDecimalFormatSymbols();
if ("US".equalsIgnoreCase(locale.getCountry())
&& "es".equalsIgnoreCase(locale.getLanguage())) {
decimalFormatSymbols.setMonetaryDecimalSeparator('.');
decimalFormatSymbols.setGroupingSeparator(',');
}
((DecimalFormat) numberFormat).setDecimalFormatSymbols(decimalFormatSymbols);
This is one way to "fix" it, but it really seems like there should be a more locale friendly way to do it.
Upvotes: 2
Views: 1655
Reputation: 3939
To answer my question; yes, this is a known bug in Android:
https://code.google.com/p/android/issues/detail?id=38844
Supposedly fixed post 4.2, but here we are at 4.2.2
Upvotes: 2