Formatting currency in Android using wrong decimal separator

筅森魡賤 提交于 2019-12-05 06:45:20

It's like your user says: In Swedish thousand separator is white space " " and decimal separator is comma "," and currency symbol "kr" (Krona). So colon ":" is definitely wrong.

You can check it here too: http://www.localeplanet.com/java/sv-SE/

What Java version are you using? It works well on my desktop 1.6.0_13

-- update --

It seems that on Android there's a bug, but you can go around the bug by using the DecimalFormatSymbols like this:

    DecimalFormat svSE = new DecimalFormat("#,###.00");
    DecimalFormatSymbols symbols = new DecimalFormatSymbols(new Locale("sv", "SE"));
    symbols.setDecimalSeparator(',');
    symbols.setGroupingSeparator(' ');
    svSE.setDecimalFormatSymbols(symbols);

This prints the correct separators in Android as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!