I'm trying to convert the system time to int
with the following code:
String today = "" + System.currentTimeMillis();
int todayInt = Integer.parseInt(today);
But I'm getting the following error:
java.lang.NumberFormatException: For input string: "1538956627792"
Why is this number: "1538956627792"
still throwing an error?
数字太长,无法解析为int
,您需要使用Long
来解析那个大数字,
long todayInt = Long.parseLong(today);
The size of int
type is 32 bit, it ranges from -2,147,483,648
to 2,147,483,647
. 1538956627792 exceeds the range, so the error caused.
you could change int
to long
to solve this problem, here is a detailed reference
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.