I am using fmt:formatNumber to format currency in JSTL, it will display negative currency in ($100) format, how do I make it display negative currency in negative format instead of ($100)?
thanks very much,
sue
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.
In the example I show two formats in the pattern attribute. One for positive values and one for negative values. They are separated with the semicolon ';'. Both are using the place holder for the currencySymbol.
Example:
<fmt:formatNumber value="-10000" type="currency" currencySymbol="$" pattern="¤ #,##0.00;¤ -#,##0.00"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With