Groovy: 将字符串转换为整数给出 NumberFormatException

Groovy: Converting a string to integer gives NumberFormatException

我正在尝试从这段文字中获取日期:

{InstantSeconds=1581504140},ISO,Europe/Paris resolved to 2020-02-12T11:42:20

我试过

def text = "{InstantSeconds=1581504140},ISO,Europe/Paris resolved to 2020-02-12T11:42:20"
text = text.replaceAll("[^\d.]", "")
text = text.substring(10)
println "${text}"

int result= Integer.parseInt("${text}");
println result

但我得到了

java.lang.NumberFormatException: For input string: "20200212114220"

我正在使用这个(练习)https://groovyconsole.appspot.com/

有人知道为什么会这样吗?

该值对于整数来说太长。使用 Long 数据类型:

Long result = text.toLong()
assert result.class.name == 'java.lang.Long'
assert result == 20200212114220