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.
Asked
Active
Viewed 1,678 times
-2

dur
- 15,689
- 25
- 79
- 125

Madhan Shah
- 1
- 1
- 4
-
1The answer is easy. Very much so in Java. *something with split string on something. – Flummox - don't be evil SE Nov 09 '16 at 09:35
-
2Possible duplicate of [How to split a string in Java](http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java) – Flummox - don't be evil SE Nov 09 '16 at 09:36
1 Answers
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