(转)一个百度的问题...

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);

======
结果:
-1325491905
-1325491552
两者只差一秒,为什么结果却差353秒呢?这是怎么回事啊?

问题地址:http://zhidao.baidu.com/question/297274433.html

--------------------------
我看了这个问题,表示我不懂
问题补充
yunzhu 写道
lc4ever 写道
这个...getTime的结果是从1970.1.1,0,0开始算的...


果然,那1970年之前的应该就有点乱了

getTime在+8的中国可不是从1970.1.1,0,0开始算的
问题补充
求来个高人分析下源码啊...我道行太浅分析不来

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秒都没有问题

关注,求解答