Reference blog post: http://blog.csdn.net/myfmyfmyfmyf/article/details/22047367
The code is as follows:
Long a = (long) (30*24*60*60*1000); Long b = 30l*24l*60l*60l*1000l; System.out.println("a = " + a); System.out.println("b = " + b);operation result
a = -1702967296 b = 2592000000The reason is: 30*24*60*60*1000 is calculated according to the int type, and then converted from int to long, but the result of 30*24*60*60*1000 exceeds the maximum range of the int type (2147483647), So it overflowed, resulting in a negative result. So when calculating large values, remember to use the form of 30l*24l*60l*60l*1000l to calculate