• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the overridden currency symbol from the Windows?

 
Alex Worker
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1697
30
Firefox Browser IntelliJ IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ;).
 
Alex Worker
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

That question is too difficult for “beginning”, so I shall move it.
 
Martin Vajsar
Sheriff
Pie
Posts: 3747
62
Chrome Netbeans IDE Oracle
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I have moved it now.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic