【问题标题】:How do you get Indonesian Rupiah currency formater with `getCurrencyInstance` in Android? What about other locales such as Albanian Lek?如何在 Android 中使用“getCurrencyInstance”获取印尼盾货币格式?阿尔巴尼亚列克等其他地区呢?
【发布时间】:2020-10-04 14:49:31
【问题描述】:

基本上,我想将字符串编号格式化为看起来合适的本地格式。 例如,“15000”看起来或多或少像我的语言环境货币格式。 即“Rp.15.000”

【问题讨论】:

    标签: android currency number-formatting currency-formatting numberformatter


    【解决方案1】:

    基本上,问题的出现是因为您的 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");

    等等。

    【讨论】:

      猜你喜欢
      • 2014-10-26
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多