3

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.

1 Answer 1

6

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.