tags:

views:

259

answers:

4

Is there a way to get a text description of the currency represented by a Currency object in Java?

i.e. I have AZM, I want Azerbaijan Manat

+4  A: 

Such a mapping would again be Locale-dependent… I think your best bet would be to take a long, hard look at ISO 4217 and create a Map from currency code to currency name.

Bombe
+2  A: 

Not in the standard API. The data behind the Currency class is loaded from the package-private class java.util.CurrencyData, and there's simply no text description present there. You can look at it if you have the source code installed with your JDK.

Michael Borgwardt
+2  A: 

You will have to set up your own mapping. Google or Stackoverflow questions will point to the ISO site

However you'll have to scrape the page as there seems to be no XML or text file as there is for country

Mark
The ISO site you've linked to is the country code list. Is that what you really want ?
Brian Agnew
oops I'll edit
Mark
yep, that's what I figured. Oh well :)
Brabster
+2  A: 

It's not supported by Java but a few libraries can do this.

My number one choice would be ICU,

http://icu-project.org/apiref/icu4j/com/ibm/icu/util/Currency.html#getName%28java.util.Locale,%20int,%20boolean%5B%5D%29

This call can get you the name of a currency in multiple locales. ICU also supports all other i18n features not available in JRE. However, it's pretty big.

Another option is jPOS,

http://gl.jpos.org/

If you do anything with financial data, this is the de-facto standards. Watch for its license. Our lawyers didn't like it for some reason.

ZZ Coder