【发布时间】:2020-10-04 14:49:31
【问题描述】:
基本上,我想将字符串编号格式化为看起来合适的本地格式。 例如,“15000”看起来或多或少像我的语言环境货币格式。 即“Rp.15.000”
【问题讨论】:
标签: android currency number-formatting currency-formatting numberformatter
基本上,我想将字符串编号格式化为看起来合适的本地格式。 例如,“15000”看起来或多或少像我的语言环境货币格式。 即“Rp.15.000”
【问题讨论】:
标签: android currency number-formatting currency-formatting numberformatter
基本上,问题的出现是因为您的 Locale 常量不容易获得。
也就是说,没有Locale.INDONESIAN,或Locale.ALBANIAN,或Locale.LATVIAN这样的东西。
TL;印尼盾格式的DR:
Locale myIndonesianLocale = new Locale("in", "ID");
NumberFormat formater = NumberFormat.getCurrencyInstance(myIndonesianLocale);
这是印尼语言环境,其他语言环境呢?
转至:https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html (请注意语言标签)。
对于阿尔巴尼亚语语言环境对:sq-AL:
Locale myAlbanianLocale = new Locale("sq", "AL");
对于拉脱维亚语言环境对:lv-LV
Locale myAlbanianLocale = new Locale("lv", "LV");
等等。
【讨论】: