Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get numeric value of a currency code?  RSS feed

 
Naresh Gunda
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In java 1.6, how can we get the numeric value of a currency code as per ISO 4217. (Eg. for INR numeric value is 356 )

Thanks in advance
 
Greg Charles
Sheriff
Posts: 3015
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a java.util.Currency class. Unfortunately for you, it will only let you convert from the three letter code to the currency symbol, not the numeric code. It delegates most of its work to the class com.ibm.icu.util.Currency, but that also doesn't seem to have any interface to return the numeric code. Probably they didn't consider it to be a useful piece of information.

If you really need that conversion, you're probably stuck with downloading the ISO 4217 data, and writing your own converter. You might even try extending Currency to do it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!