Set decimal separator when using f:convertNumber

前端 未结 1 1309
礼貌的吻别
礼貌的吻别 2020-11-28 15:42

I want to know how to set the default decimal separator on my JSF application. I have some that I need to format as money, with 2 decimals.

1条回答
  •  孤城傲影
    2020-11-28 16:10

    The default decimal separator depends on the locale used. You can set it in 2 ways:

    1. On a per-view basis by the locale attribute of the tag:

       
      
    2. On a per-converter basis by the locale attribute of the tag:

       
      

    It's unclear what locale you're targeting, but the use of . as fraction separator is typical for US dollars with a locale of en-US, for example. So you need to set it as such:

    
    

    It can also be obtained from a java.util.Locale bean property.

    
    

    Note that I used type="currency", that's more self-documenting.

    See also:

    • Does use the right number separator when using patterns to format currency?
    • Localization in JSF, how to remember selected locale per session instead of per request/view

    0 讨论(0)
提交回复
热议问题