File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to get locale instance by currency symbol in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to get locale instance by currency symbol in java?" Watch "how to get locale instance by currency symbol in java?" New topic
Author

how to get locale instance by currency symbol in java?

Madhavi Subramaniam
Ranch Hand

Joined: Nov 24, 2011
Posts: 33
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

Joined: Jan 08, 2009
Posts: 1449
    
    6

Does this help?


Swastik
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1753
    
    7

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.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Nov 24, 2011
Posts: 33
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

Joined: Oct 13, 2005
Posts: 37891
    
  22
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get locale instance by currency symbol in java?
 
Similar Threads
Question related to java.util.Currency's getSymbol method.
Here's a fun one..
Getting currency symbols
Localized Currency formatting issue
Why is Locale not working here?