nightingale2k1 nightingale2k1 - 6 months ago 14
Java Question

formatNumber : how to add 2 decimal digits at the back of numbers?

I am using grails formatNumber and I would like to display my numbers in decimal format.

I would like to display 10 as 10.00
or 0 as 0.00 with 2 decimal digits.

how to do that ?

Answer

I believe that you were looking for how to do this with Grails' formatNumber tag

<g:formatNumber number="${10}" format="0.00"/>
<g:formatNumber number="${0}" format="0.00"/>

results in

10.00
0.00

The formatNumber tag uses DecimalFormat for the format parameter

Comments