public void test() {
long to = System.currentTimeMillis();
long from = to - 30*24*3600*1000L; 长整型减长整型
long ft = to - 30*24*3600*1000; //30*24*3600*1000 == 2592000000,会因为越界,超过了int字节的范围(int范围位 -2147483648~2147483647),会变成一个负数 -1702967296
int t = (int)to / 1000; //长整型先压缩变成了负数,再去除10000,压缩有可能正有可能负,但如果低数据类型装不下则会出现错误。
long f = from / 1000; //先压缩
int dd = (int)(from / 1000); //先将long整型压缩了,再强转到int,这是int数据类型可以装下,故准确
System.out.println(to);
System.out.println(from);
System.out.println(ft);
System.out.println(t);
System.out.println((int)f);
System.out.println(dd);
System.out.println(Integer.MAX_VALUE); //2147483647
System.out.println(30*24*3600*1000);
}
//时间戳是13位