Home >Java >javaTutorial >How can I format Indian Rupee (INR) currency values in the Indian numbering system?
Formatting Currency in Indian Numbering Format
Question:
How can I format Indian Rupee (INR) currency values in the Indian numbering system, where numbers are separated by commas after two digits, except for the last set, which is in thousands?
Answer:
Java's standard DecimalFormat class does not support variable-width grouping, so it cannot format values precisely as required.
Solution:
To correctly format INR values in the Indian numbering system, consider using the ICU4J NumberFormat class. Here's an example:
<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 will produce the following output:
Rs 10,00,00,000.00
Additional Notes:
The above is the detailed content of How can I format Indian Rupee (INR) currency values in the Indian numbering system?. For more information, please follow other related articles on the PHP Chinese website!