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

标签 java android numberformatexception

我正在尝试使用以下代码将系统时间转换为 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/

相关文章:

java - ZXing SCAN_RESULT if 语句

java - JTextField 值上的 NumberFormatException

java - java中无法将字符串转换为int

java - Eclipse 中的 Maven 编译器警告和错误

java - 带有 @Value 注释和单个方法的字段。我应该让它们都静态吗?为什么/为什么不呢?

android - 如何使 Jetpack Compose DropDown Menu 弹出项目更宽?

android - 将 unicode 符号插入到 edittext

Java:条件语句的逻辑不起作用,即使不满足条件也允许程序运行

java - 如何在我的程序中仅创建一个 Scanner 对象

java - 如何为listView中的特定项目添加点击