以印度编号格式显示货币 [英] Displaying Currency in Indian Numbering Format

查看:151
本文介绍了以印度编号格式显示货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有关于格式化卢比货币(印度卢比 - 印度卢比)的问题。

I have a question about formatting the Rupee currency (Indian Rupee - INR).

通常值 450500 已格式化并显示为 450,500 。在印度,相同的值显示为 4,50,500

Typically a value like 450500 is formatted and shown as 450,500. In India, the same value is displayed as 4,50,500

例如,此处的数字表示为:

For example, numbers here are represented as:

1
10
100
1,000
10,000
1,00,000
10,00,000
1,00,00,000
10,00,00,000

请参阅印度编号系统

分隔符在两位数之后,最后一组除外,数千位。

The separators are after two digits, except for the last set, which is in thousands.

我在互联网上搜索过,人们要求使用locale en_GB 或模式#,##,##,##,## 0.00

I've searched on the internet and people have asked to use the locale en_GB or pattern #,##,##,##,##0.00

我在JSTL上尝试使用以下标记:

I tried this on JSTL by using the following tag:

<fmt:formatNumber value="${product.price}" type="currency" 
  pattern="#,##,##,##,###.00"/>

但这似乎无法解决问题。任何有关此事的帮助将不胜感激。

But this does not seem to solve the issue. Any help in this matter will be greatly appreciated.

谢谢

推荐答案

不幸的是 DecimalFormat 不支持可变宽度组。因此,它不会完全按照您的要求格式化值:

Unfortunately DecimalFormat doesn't support variable-width groups. So it won't ever format the values exactly as you want to:


如果提供具有多个分组字符的模式,则为最后一个和整数的结尾是使用的那个。所以#,##,###,####==######,####==##,####,## ##

Java中大多数数字格式化机制都基于该类,因此继承了这个缺陷。

Most number formatting mechanisms in Java are based on that class and therefore inherit this flaw.

ICU4J(国际组件的Java版本) Unicode )提供 支持此格式的

ICU4J (the Java version of the International Components for Unicode) provides a NumberFormat class that does support this formatting:

Format format = com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in"));
System.out.println(format.format(new BigDecimal("100000000")));

此代码将产生此输出:

Rs 10,00,00,000.00

注意: com.ibm.icu.text.NumberFormat class 扩展 java.text.NumberFormat class(因为它已经扩展了ICU内部基类),确实但扩展了 java.text.Format 类,其中包含 format(Object) method。

Note: the com.ibm.icu.text.NumberFormat class does not extend the java.text.NumberFormat class (because it already extends an ICU-internal base class), it does however extend the java.text.Format class, which has the format(Object) method.

这篇关于以印度编号格式显示货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆