首页 > 解决方案 > 使用 ISO 4217 的 CurrencyCode 格式化 pl_PL 价格

问题描述

我需要BigDecimal根据 ISO 4217 将价格(as )格式化为波兰货币格式。根据https://en.wikipedia.org/wiki/ISO_4217#Active_codes和我的接受标准,这种格式应该始终有 2 位小数。

所以我有 pl_PL 的 Java-Locale 对象和相关CurrencyUnit 985的 from ISO 4217,我可以在调试器中看到。现在,当我想格式化以下价格时,我遇到了一些问题:

所以我做了一些调试,我发现Java从类中读取了pl_PL相关的定价,它的定义如下:DecimalPatternFormatData_pl_PL.java

{ "NumberPatterns",
new String[] {
"#,##0.###;-#,##0.###", // decimal pattern
"#,##0.## \u00A4;-#,##0.## \u00A4", // currency pattern
"#,##0%" // percent pattern
}
},

上面的模式将在这种情况下使用:

NumberFormat format = NumberFormat.getCurrencyInstance(locale);
DecimalFormat decimalFormat = (DecimalFormat) format;
String pattern = getSimplePattern(locale, currency);
decimalFormat.applyPattern(pattern);
return decimalFormat.format(price);

所以给定的货币模式似乎不正确。按照ISO 4217它应该是"#,##0.00",不是吗?

我该如何处理这个问题?

标签: java

解决方案


推荐阅读