Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting currency symbols

 
Rich Davies
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

This is my first attempt at playing with currencies in Java and I'm struggling with a problem. Basically I have a page that displays a list of available currencies. This list is derived from a database table which has the currency names and ISO 4217 currency codes (i.e. USD, GBP etc). The list is created by selecting all of the currencies from this table and loading them into a list of java.util.Currency objects, where each Currency object is created like so:



I then iterate over that list calling the Currency.getSymbol() method for each currency to display the appropriate symbol for each one. The problem is that it doesn't. All that gets displayed is the currency code for each currency, except for Euros and GBP where the appropriate � or � symbol is displayed. I've read around and it appears that this is because my default Locale is set to the UK and indeed when I change the Locale to the US for example, then USD appear as $ and Euro's don't!

So what I would like to know is is it possible in java to get a currency's symbol using only a currency code and without having to change the default Locale? Or am I better off just adding another column to my database and storing symbols in there?

Thanks

Rich
 
Paul Clapham
Sheriff
Pie
Posts: 20184
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the documentation for the getSymbol(Locale) method? It tries to explain why you are seeing what you are seeing.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic