Groovy adds several methods to the String
class we can use to determine if the String value can be parsed into a Number
or related class like BigDecimal
.
def n = '42.01' def i = '201' assert n.isNumber() && n.isBigDecimal() && n.isFloat() && n.isDouble() assert i.isInteger() && i.isLong() && i.isBigInteger()