Search code examples
javacurrencycountry-codes

How to convert a country code to the corresponding currency?


I need to convert a country code to a currency in my app on a user basis.

Based on my geolocation library, I know whether the user is in the United States (US), Germany (DE), Switzerland (CH), Japan (JPY), etc. Now I need to convert from the country code to the corresponding currency:

US -> USD ($)
DE -> EURO (€)
CH -> CHF (CHF)
JP -> YEN (JPY)

How can I do this in Java?


Solution

  • You should parse this page and store it in your database.

    It's hard to build good databases suited to an apps need from Internet sources, but it's really worth it. To parse html, I suggest you try regexp, and if it gets too complicated, please use apache jericho or tag soup.