Search code examples
jsfconverterscurrencynegative-number

ConvertNumber do JSF negative values


The negatives monetaries values, when i use the JSF's native conversor, <f:convertNumber type="currency"/>, keeps the character '-' before the currency symbol.

For example: -$ 56.134.726,99

.xhtml

<p:column>
    <h:outputText value="#{entity.monetaryValue}">
        <f:convertNumber type="currency"/>
    </h:outputText>
</p:column>

Is there any solution to this problem different from creates my own Converter?


Solution

  • What about:

    <f:convertNumber type="currency" currencySymbol="$" locale="DE" 
          pattern="¤###,###,##0.00;¤-###,###,##0.00"    />
    

    The pattern is described here


    Note: I use locale="DE" because in this locale , is used as decimal separator, and . as group separator.