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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -