how to format a number with new Indian currency symbol(₹) using java.if there is any workaround let us share .
Until Java properly supports the new character you can manually specify the currency symbol using its unicode value.
The Unicode for the Indian currency symbol is U+20B9
So to insert this character into a java string you specify it as \u20B9
instead of the default DecimalFormat currency value of \u00A4
For example:
DecimalFormat formatter = new DecimalFormat("\u20B9 000");
Unfortunately this will hard code your output to always display the rupee symbol. If you need to support multiple locales you can check the user.country system property.
boolean iAmInIndia = "IN".equals(System.getProperty("user.country"));
DecimalFormat formatter = iAmInIndia ? new DecimalFormat("\u20B9 000") : new DecimalFormat("\u00A4 000");
Also, the component you are using to display this string must have a font which contains the currency symbol. Arial on Window 7 does, however many others don't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With