Formatting Currency in Indian Numbering Format
Formatting currency in Indian numbering format can be challenging, as it differs from standard Western notation. Typically, a value like 450500 is written as 4,50,500 in India. This article explores the nuances of Indian currency formatting and provides a suitable solution using ICU4J.
The Indian numbering system uses commas to separate digits in groups of two, except for the last group, which is separated by thousands. For example:
Java's standard DecimalFormat class does not support variable-width groups, making it unsuitable for this task. However, the ICU4J NumberFormat class overcomes this limitation.
<code class="java">Format format = com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in")); System.out.println(format.format(new BigDecimal("100000000")));</code>
This code outputs:
Rs 10,00,00,000.00
Note that the ICU4J NumberFormat class extends Format, not NumberFormat. In the Android version of DecimalFormat, this feature is supported as well, as it is implemented using ICU.
The above is the detailed content of How to Format Currency in Indian Numbering System Using ICU4J?. For more information, please follow other related articles on the PHP Chinese website!