I want to get the currency format of India, so I need a Locale
object for India. But there exists only few a countries that have a Locale
constant (a static final Locale
), and India is not one of them.
To get the currency symbols for the US and UK, I can do the following:
public void displayCurrencySymbols() {
Currency currency = Currency.getInstance(Locale.US);
System.out.println("United States: " + currency.getSymbol());
currency = Currency.getInstance(Locale.UK);
System.out.println("United Kingdom: " + currency.getSymbol());
}
That uses the constants Locale.US
and Locale.UK
. If i want to get the Indian currency format, what can I do?
According to the JDK release notes, you have locale codes hi_IN
(Hindi) and en_IN
(English).
System.out.println(Currency.getInstance(new Locale("hi", "IN")).getSymbol());