码迷,mamicode.com
首页 > 编程语言 > 详细

java 比较时间的几种方法

时间:2019-10-02 10:20:24      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:new   com   ati   pre   compare   print   time()   ret   gettime   

public class Test {
    public static void main(String[] args) {
        Date date1 = new Date();
        Date date2 = new Date(date1.getTime() + 1000);

        System.out.println(date1.before(date2));
        System.out.println(date1.compareTo(date2) == -1);
        System.out.println(date1.getTime() < date2.getTime());
    }
}

java 比较时间的几种方法

标签:new   com   ati   pre   compare   print   time()   ret   gettime   

原文地址:https://www.cnblogs.com/xmsx/p/11616663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!