• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get locale instance by currency symbol in java?

 
Madhavi Subramaniam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to get the locale instance by using currency symbol.

For Ex: Input : $
Output : Locale.US

I have googled lot to find utility for this conversion , i couldnt find any solution . Please javaRanch experts give me some ideas to resolve this problem.


Thanks in Advance




 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this help?
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Such a reverse look-up doesn't really make sense to me. In your example the currency symbol "$" is used to signify the US Dollar in the en_US locale, en_CA and nl_NL locale, to name just a few. Moreover, in the same locales it is also used to signify not only the US Dollar, but the Canadian Dollar, New Zealand Dollar, and many other currencies. Anyway, since this is not threading related, I'm moving this to Java in General.
 
Paul Clapham
Sheriff
Posts: 21111
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which locale would you expect to get from the Euro symbol?

(In case you didn't know, the Euro is the official currency of a couple of dozen countries in Europe.)
 
Madhavi Subramaniam
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all... so for many locales we have a single currency symbol.... so we should know the Locale exactly so that we can format the number currectly...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Madhavi Subramaniam wrote: . . . we should know the Locale exactly so that we can format the number currectly...
Yes. If you go to France or Germany and buy something, it might cost €1.234,56. The same item for the same price in Ireland would cost €1,234.56. Do you see the difference?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic