Home > Java > javaTutorial > body text

How to Format Indian Rupees (INR) in the Indian Numbering System?

DDD
Release: 2024-10-25 08:32:28
Original
965 people have browsed it

How to Format Indian Rupees (INR) in the Indian Numbering System?

Displaying Currency in Indian Numbering Format

Question:

How can I format the Indian Rupee currency (INR) in the Indian numbering system, where numbers are separated by commas after two digits, except for the last set, which is in thousands?

Answer:

Unfortunately, Java SE's standard DecimalFormat does not support variable-width grouping, making it impossible to format numbers according to the Indian numbering system.

However, ICU4J (International Components for Unicode) provides a NumberFormat class that supports this format:

<code class="java">Format format = com.ibm.icu.text.NumberFormat.getCurrencyInstance(new Locale("en", "in"));
System.out.println(format.format(new BigDecimal("100000000")));</code>
Copy after login

Output:

Rs 10,00,00,000.00
Copy after login

Note that the Android version of java.text.DecimalFormat class is implemented using ICU under the hood and supports the variable-width grouping feature as well.

The above is the detailed content of How to Format Indian Rupees (INR) in the Indian Numbering System?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!