Search code examples
javavelocity

How to convert a String to Integer for use in a loop in Velocity?


The $pod.id and $SplitMap.get("$pod.id") are not null.

This loop also works:

#set($start = 0)
#set($end = 1)

But this is not working:

#set($start = 0)
#set($end = $Integer.parseInt($SplitMap.get("$pod.id")))

It gives Exception:

#set($start = 0)
#set($end = $Integer.parseInt("$SplitMap.get("$pod.id"))")

Solution

  • This is working internally for val template takes something which is commented

    #set($val =1)
    //Integer val = new Integer();
    #set($start = 0)
    #set($end = $val.parseInt($SplitMap.get("$pod.id")))