AnsweredAssumed Answered

Number format exception while converting string to integer using groovy scripting

Question asked by k12345 on Sep 29, 2017
Latest reply on Oct 3, 2017 by k12345

Hi ,

 

In below code i am reading a value from database and then converting it into integer to convert it in IPV4 format. But getting exception - javax.script.ScriptException: java.lang.NumberFormatException: while running it in ITR

 

String a = "{{START_IP}}"
//a= "99993699"
def startIP =Integer.valueOf(a)
def IPString1 = ((startIP >> 24 ) & 0xFF) + "." + ((startIP >> 16 ) & 0xFF) + "." + ((startIP >> 8 ) & 0xFF) + "." +(startIP & 0xFF);

return IPString1

 

But if I test the script in Execute script(JSR-223) step using hardcode values it returns correct IP address. Can anyone please let me know is there anything I need to update to run it as Groovy script.

Outcomes