html tool

2017年5月2日星期二

pipeline : string2int

add:http://stackoverflow.com/questions/1713481/groovy-string-to-int

Use the toInteger() method to convert a String to an Integer, e.g.
int value = "99".toInteger()
An alternative, which avoids using a deprecated method (see below) is
int value = "66" as Integer
If you need to check whether the String can be converted before performing the conversion, use
String number = "66"

if (number.isInteger()) {
  int value = number as Integer
}

没有评论:

发表评论