Round values in template

Andreas Kern3 years ago

Hello,
i try to find a way to use math.roundTo(Object decimals, Object num) in velocity template.

I want to round some temperature values which sometimes are displayed in a massage as
20.28754 °C , and i want them to be displayed like 20.3 °C for example.

This is what i found on google and what i tried in test message.

#set($mathTool = $serviceLocator.findService("org.apache.velocity.tools.generic.MathTool"))
#set($rounded = $mathTool.roundTo(2 , 123.258))
Testmessage $rounded 

The result i get in push notification is:

Testmessage $rounded

Perhaps someone here has got a solution or idea to get this thing done.