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++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -