I have BigDecimal property in model. Is's storing money value . Now i want to show money in 123 456 789,00 format.
i want to do it in view part of application. I am using Spring framework.
what is a best practise to do it?
I have BigDecimal property in model. Is's storing money value . Now i want to show money in 123 456 789,00 format.
i want to do it in view part of application. I am using Spring framework.
what is a best practise to do it?
The best way to format money value in the JSP view is to use JSTLs.
For example:
<fmt:formatNumber currencySymbol="$" type="number" maxIntegerDigits="2" value="${balance}" />
In your case you may have to set a different pattern (to display the space after each 3 numbers)
http://www.tutorialspoint.com/jsp/jstl_format_formatnumber_tag.htm
if you are working with jsf you can use
<h:outputText id="balance" value="#{accountBean.balance}">
<f:convertNumber currencySymbol="$" groupingUsed="true"
maxFractionDigits="2" type="currency" />
</h:outputText>
Another example specifiying locale:
<h:outputText value="#{llistaV.importTotal}"rendered="#{llistaV.importTotal != null}">
<f:convertNumber currencySymbol="$" maxFractionDigits="2" type="currency" locale="es-ES"/>
<!-- pattern="###,###.###$" -->
</h:outputText>