java.util.Date before()函数为1个月之前的日期提供false

时间:2014-08-16 03:53:10

标签: java date

以下是代码段:

public static void main(String[] args) {
        // TODO code application logic here
        long oneMonthAgo=30*24*60*60*1000;
        Date now = new Date();
        Date twf=new Date(now.getTime()-oneMonthAgo);
        System.out.println(twf.before(now));
    }

这输出错误

虽然这段代码如下:

public static void main(String[] args) {
        // TODO code application logic here
        long twentyDaysAgo=20*24*60*60*1000;
        Date now = new Date();
        Date twf=new Date(now.getTime()-twentyDaysAgo);
        System.out.println(twf.before(now));
    }

输出:True

不够奇怪 ?

0 个答案:

没有答案