-2

I have situation where I'll get a string amount in the form of 100.00, 100, 1.00 or any other amount. My question is: can I format it without decimal places? 100.00 should be displayed as 100, 1.00 should be displayed as 1. So decimal places shouldn't be displayed. How can I achieve this in Velocity template? I have tried number tool in Velocity template. But it's printing $numberTool.format() itself. So any help would be appreciated.

dur
  • 15,689
  • 25
  • 79
  • 125
Madhan Shah
  • 1
  • 1
  • 4

1 Answers1

0

if you are expecting integer value then please try to use the yourfieldName.intValue() to get the integer value in your velocity template. Or you can assign the value without decimal point at java side and directly get them in your Velocity it wil print the value without decimal. If you are using your field as double then use the below code to get the result without decimal point.

new DecimalFormat("#").format('your variable which hold the double value');
Zia
  • 1,001
  • 1
  • 13
  • 25