Below program prints the Currency symbol given the ISO 4217 currency code.
import java.util.*;
public class Currency{
public static void main(String args[]
Currency.getSymbol() returns the currency symbol relative to the default locale.
Gets the symbol of this currency for the default locale. For example, for the US Dollar, the symbol is
"$"
if the default locale is the US, while for other locales it may be"US$"
. If no symbol can be determined, the ISO 4217 currency code is returned.
Use Currency.getSymbol(Locale locale) if you want the symbol for a different locale.
System.out.println(
Currency.getInstance("USD").getSymbol(Locale.US)
);
// prints $
System.out.println(
Currency.getInstance("USD").getSymbol(Locale.FRANCE)
);
// prints USD
System.out.println(
Currency.getInstance("EUR").getSymbol(Locale.US)
);
// prints EUR
System.out.println(
Currency.getInstance("EUR").getSymbol(Locale.FRANCE)
);
// prints €
(see also on ideone.com).