我正在尝试使用以下代码将系统时间转换为 int
:
String today = "" + System.currentTimeMillis();
int todayInt = Integer.parseInt(today);
但我收到以下错误:
java.lang.NumberFormatException: For input string: "1538956627792"
为什么这个号码:“1538956627792”
仍然抛出错误?
最佳答案
数字太长,无法解析为int
,您需要使用Long
来解析那个大数字,
long todayInt = Long.parseLong(today);
关于java.lang.NumberFormatException : For input string: "1538956627792",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52998163/