SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str3 = "1927-12-31 23:54:07";
String str4 = "1927-12-31 23:54:08";
Date sDt3 = sf.parse(str3);
Date sDt4 = sf.parse(str4);
long ld3 = sDt3.getTime() /1000;
long ld4 = sDt4.getTime() /1000;
System.out.println(ld3);
System.out.println(ld4);
http://stackoverflow.com/questions/6841333/a-very-strange-date-before-1970
It's a time zone change on December 31st in Shanghai.
See this page for details of 1927 in Shanghai. Basically at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. So "1927-12-31 23:54:08" actually happened twice, and it looks like Java is parsing it as the later possibly instant for that local date/time - hence the difference.
Just another episode in the often weird and wonderful world of time zones.
在1927年底时间修改了……
如果两个时间离现在比较近,就没有问题,比如1977年,同样很疑惑 :oops:
这个...getTime的结果是从1970.1.1,0,0开始算的...
[quote="lc4ever"]这个...getTime的结果是从1970.1.1,0,0开始算的...[/quote]
果然,那1970年之前的应该就有点乱了 :idea:
而且只有07-08秒有问题
06-07和08-09秒都没有问题
关注,求解答