在两个具有不同时区的java日期之间经过的天数

时间:2014-04-12 11:46:27

标签: java excel date time timezone

我有两个日期,但一个是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过去的日子?

1 个答案:

答案 0 :(得分:2)