Fmt: formatNumber displays negative currency in the format $ xxx.xx in JSTL

I use fmt: formatNumber to format the currency in JSTL, it displays negative currency in ($ 100) format, how do I display negative currency in negative format instead of ($ 100)?

Many thanks,

Sue

+3
source share
3 answers

I would suggest: <fmt:formatNumber type="currency" pattern="$#,##0.00;-$#,##0.00" value="-10000" />

You can remove the '$' from the template if you wish.

+2
source

If you use the pattern attribute and want to display a currency symbol, you need to add a currency symbol symbol (¤) holder to the template itself. ¤ will be replaced by the given CurrencySymbol value.

pattern. . ';'. Symbol.

:

<fmt:formatNumber value="-10000" type="currency" currencySymbol="$" pattern="¤ #,##0.00;¤ -#,##0.00"/>
+11

Just add, if u uses the type as curreny, then the currency code is required, otherwise a random character is displayed. If you do not want to use currencyCode [it will be ldisplay, which each u indicated in currecyCode], then use a template, for example

<fmt:formatNumber type="currency" pattern="#,##0.00;" value="-10000" />
+1
source

Source: https://habr.com/ru/post/1735938/


All Articles