1

Hi All: I receive a decimal in string format and want to convert it to Integer in groovy. could not find any solution so far. For eg: I get the string value as "100.0" and I need the output as 100. Please help.

I plan to run this groovy script in boomi.

NK7983
  • 125
  • 1
  • 14

1 Answers1

4

First convert to float, then to integer:

def s = "100.0"
def f = s.toFloat()
def i = f.toInteger() //or (int)f

or one line,

def i = "100.0".toFloat().toInteger()
aldrin
  • 4,482
  • 1
  • 33
  • 50