问题
how to format a number with new Indian currency symbol(₹) using java.if there is any workaround let us share .
回答1:
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.
回答2:
https://www.karnataka.gov.in/Documents/Rupee_Foradian.ttf copy this font in windows fonts folder(in RUN ->type fonts).
then Font ProMed_Font=new Font("Rupee Foradian",Font.PLAIN,10); set above font to label
example:label.settext("100"+"`") output will be 100+rupee symblol

来源:https://stackoverflow.com/questions/11309205/support-new-indian-currency-symbol-in-java