*
The moose likes General Computing and the fly likes How to get the overridden currency symbol from the Windows? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "How to get the overridden currency symbol from the Windows?" Watch "How to get the overridden currency symbol from the Windows?" New topic
Author

How to get the overridden currency symbol from the Windows?

Alex Worker
Greenhorn

Joined: Jan 27, 2014
Posts: 3
How in Java to get the current(overridden) currency symbol from the Windows?
As you know t is possible in Windows (Control Panel->Region->Additional Settings->Currency) change currency symbol to the new one.
For example default is '$' and customer change it to the '€'
And programs (Excel for example) use this new currency symbol, i.e instead of $100 you see €100.

I need emulate similar behavior in Java.
Paweł Baczyński
Bartender

Joined: Apr 18, 2013
Posts: 842
    
  14

There is a class NumberFormat. It has a static factory method that returns currency format instance for the current locale (if given no parameters).
Next, this instance has a method that returns a Currency object.
Next, this curreccy object has a method that returns its symbol as a String.

Let me know if you found this. If not I can give you more precise answer ;).


Formely Pawel Pawlowicz
Alex Worker
Greenhorn

Joined: Jan 27, 2014
Posts: 3
I know how to get DEFAULT currency symbol for locale.
This is a case when regular symbol is overriden, what I really explain above.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Welcome to the Ranch

That question is too difficult for “beginning”, so I shall move it.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

I was having similar issue with decimal separator - Windows regional settings allow the locale default decimal separator to be overridden, but the JRE simply ignores the override. We ended up coding a small dll which used Windows API to read the actual value of the decimal separator and made sure to use this value throughout the application. Another alternative might be to allow users set their preferred currency symbol in your application independently. Both solutions have obvious drawbacks, but the JRE simply doesn't support the regional settings locale overrides (as far as I know).
Alex Worker
Greenhorn

Joined: Jan 27, 2014
Posts: 3
Martin Vajsar wrote:I was having similar issue with decimal separator - Windows regional settings allow the locale default decimal separator to be overridden, but the JRE simply ignores the override. We ended up coding a small dll which used Windows API to read the actual value of the decimal separator and made sure to use this value throughout the application. Another alternative might be to allow users set their preferred currency symbol in your application independently. Both solutions have obvious drawbacks, but the JRE simply doesn't support the regional settings locale overrides (as far as I know).

Thank you. After investigation I got the same thoughts.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
Well, I have moved it now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get the overridden currency symbol from the Windows?
 
Similar Threads
How to set a mask for JFormattedTextFields for currency?
Currency Symbol Issue in iText
Big Decimal Currency Formatting
Getting currency symbols
Why is Locale not working here?