Number Formatting in Velocity Template upto atleast 2 decimal points

661 views Asked by At

I have to format given character [132233.2453] like this -> 132,233.2453

current code -> $number.format("###,###.##00", $value)

which seems to be working fine, but for character [295] -> it should be 295.00 [minimum 2 characters after decimal points] but it is coming 295 [without any decimal points]

1

There are 1 answers

0
Claude Brisson On

In Velocity, double quoted strings are interpolated. And in an interpolated string, ## starts a line comment. So basically your formats are empty.

Also, the decimal specification should be 00## and not ##00.

So try: $number.format('###,###.00##', $value)