I am facing an issue with fmt:formatNumber jstl tag. I am not able to display the currency symbol. It just contains the amount/ currency value. I tried using currencySymbol ($) as well as currencyCode as USD, but it did not work. Can anyone let me know what is wrong with the code?
The code is:
If the value of price is 2000, c:out displays the amount 2,000 without the currency symbol ($)
Any help is greatly appreciated.
Thanks.
bond hello
Greenhorn
Joined: Apr 15, 2011
Posts: 1
posted
0
try by removing the pattern attribute because it might override the currency attributes.
If you use the pattern attribute and you want to display the currency symbol, then you have to add the currency symbol place holder ( ¤ ) to the pattern itself.
The ¤ will be replaced with the given currencySymbol value.
for example:
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 879
posted
0
Hmm. I knew of the possibility of having a currency symbol in a number format string, but I've never actually done it.
My question: what is that symbol placeholder that is being used, and how do I type it on my keyboard???
It looks like an x with a small circle in the middle of it, and is a character I've never really seen before.
Bear Bibeault
Author and opinionated walrus
Marshal
As Bear said, it is unicode \u00a4, but you can always copy it from this page or the javadoc page ;-). I really don't understand why they chose this character and not just a simple one!
Bear Bibeault
Author and opinionated walrus
Marshal
Merlin Weemaes wrote:As Bear said, it is unicode \u00a4, but you can always copy it from this page or the javadoc page ;-).
On a Mac, enable Unicode input in System Prefs, and use the Option key to enter the unicode hex value to create the symbol. I'm sure Windows must have something similar.
Merlin Weemaes wrote:I really don't understand why they chose this character and not just a simple one!
See the links in my reply. It's the symbol that means "some currency". Why shouldn't they use it?