How to convert string into integer in the Velocity template?

velocity

Solution

Aha! Been there.

#set($intString = "9")
#set($Integer = 0)
$Integer.parseInt($intString)

Doing this uses the java underlying velocity. The $Integer variable is nothing more that a java Integer object which you can then use to access .parseInt

Edit: The above code is for demonstration. Of course there are ways to optimize it.

Problem

I have a Velocity template file which has the data from XML. I want to convert the string into integer type. How can I do that?

Original source