我尝试使用以下代码将系统时间转换为int
:
String today = "" + System.currentTimeMillis();
int todayInt = Integer.parseInt(today);
但是我得到了以下错误:
java.lang.NumberFormatException: For input string: "1538956627792"
为什么这个数字:"1538956627792"
仍然抛出错误?
发布于 2018-10-26 05:12:06
数字太长,无法解析为int
,您需要使用Long
来解析这么大的数字。
long todayInt = Long.parseLong(today);
https://stackoverflow.com/questions/52998163
复制相似问题