I want to know how to set the default decimal separator on my JSF application. I have some <h:inputText> that I need to format as money, with 2 decimals. Right now the decimal separator used by default is the comma , and this gives me an error when I do some operations on save. I don’t know if I can set the decimal separator to be used everytime that I use <f:convertNumber> tag.
I tried to use this:
<f:convertNumber pattern="########0.00" groupingUsed="false" />
but it still sets the comma as decimal separator.
The default decimal separator depends on the locale used. You can set it in 2 ways:
On a per-view basis by the
localeattribute of the<f:view>tag:On a per-converter basis by the
localeattribute of the<f:convertNumber>tag:It’s unclear what locale you’re targeting, but the use of
.as fraction separator is typical for US dollars with a locale ofen-US, for example. So you need to set it as such:It can also be obtained from a
java.util.Localebean property.Note that I used
type="currency", that’s more self-documenting.See also: