Java currency symbols

From EggeWiki

It's possible to get currency symbol codes out of Java, though as of version 1.6 it's a bit painful.

<geshi lang="java5">

   public static final String EURO_SYMBOL = Currency.getInstance("EUR").getSymbol(new Locale("el", "GR"));
   public static final String STERLING_POUND_SYMBOL = Currency.getInstance("GBP").getSymbol(new Locale("en", "GB"));
   public static final String US_DOLLAR_SYMBOL = Currency.getInstance("USD").getSymbol(new Locale("en", "US"));

</geshi>

The pain comes from the fact that common currency codes are only defined in the country in which they are used. This means if you use the default locale, you'll probably see the ISO 4217 value, not the symbol code.

See also