How can I format a negative currency using a Thymeleaf attribute processor? -


i need display negative currency-formatted values in table, using thymeleaf. currently, i'm using #numbers.formatdecimal achieve this, follows:

<td th:text="${'$' + #numbers.formatdecimal(value, 1, 'default', 2, 'default)}" /> 

for value greater zero, works fine:

<td>$34.50</td> 

but negative value, get:

<td>$-12.75</td> 

this isn't correct - need currency symbol moved right of minus sign. how can achieve this?

personally i'd use decimalformat apply formatting need:

<td th:text="${new java.text.decimalformat('$#,##0.00;$-#,##0.00').format(value)}" /> 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -