我有两个日期,但一个是CET,另一个是CEST。
Calendar calFrom = Calendar.getInstance();
calFrom.set( 2013, 2, 20,0,0,0);
Calendar calTo = Calendar.getInstance();
calTo.set( 2013, 3, 5,0,0,0);
long daysPassed= (calTo.getTime().getTime() - calFrom.getTime().getTime()) / (1000 * 60 * 60 * 24);
System.out.println("calFrom: " + calFrom.getTime());
System.out.println("calTo: " + calTo.getTime());
System.out.println("daysPassed: " + daysPassed);
输出结果显示:
calFrom: Wed Mar 20 00:00:00 CET 2013
calTo: Fri Apr 05 00:00:00 CEST 2013
daysPassed: 15
然而,Microsoft excel表示这两天的差异是 16 !
如何计算Excel过去的日子?
答案 0 :(得分:2)
JodaTime似乎想处理这个问题: http://kodejava.org/how-do-i-get-number-of-days-between-two-dates-in-joda/