I have a Struts 2 project where I display an item price. I want to change the format accorting to localization.
For example:
locale en_GB : 75.9
locale el_GR : 75,9
Currently I use the format in the messages for both locales :
{0,number,##0.00}
I tried changing the format in the one language to:
{0,number,##0,00}
but then the displayed price was wrong as: 0,76
(moved everything to the decimal part).
Any suggestions?
EDIT:
Note that in my case i want to FORCE the comma as decimal separator for all locales in the application.
You can use the DecimalFormat Constructor accepting both a pattern and a DecimalFormatSymbols, created by its constructor taking a Locale:
Take a look at the running demo. I've used
el_GR
by the way, withgr_GR
it seems that the decimal separator is still the dot. Not sure whatgr_GR
is.P.S: Here is an answer related to formatting patterns and TextProvider in Struts2, that might help future visitors