NumberFormat显示某些区域设置的货币的错误小数点格式

时间:2016-07-25 10:22:02

标签: java localization

对于像es-CO这样的某些语言环境,我将货币的数字格式十进制标记视为不正确:

 NumberFormat numberFormat =
 NumberFormat.getCurrencyInstance(new Locale("es", "CO"));
 numberFormat.setCurrency(Currency.getInstance("COP"));

 String currencyString = numberFormat.format(164900.12);
 System.out.println(currencyString);

为此我得到结果为164.900,21,而当我检查网站时:http://www.xe.com/currencyconverter/convert 我得到了其他方式,即164,900.21 这是NumberFormat类的问题还是我做错了什么。

1 个答案:

答案 0 :(得分:0)

请检查Locale类的构造函数,它首先是语言,然后是国家/地区代码

DataItem

像这样更改您的代码,您将获得类似“COP 164,900.12”的输出

 public Locale(String language, String country) {
    this(language, country, "");
 }