日期比较

Date shsj1 = new Date();
Date shsj2 = new Date();

Calendar instance1 = Calendar.getInstance();
Calendar instance2 = Calendar.getInstance();

instance1.setTime(shsj1);
instance2.setTime(shsj2);

if(instance1.compareTo(instance2)==1){
  sout.println(">");
}
if(instance1.compareTo(instance2)==0){
  sout.println("=");
}
if(instance1.compareTo(instance2)==-1){
  sout.println("<");
}
posted @ 2021-03-09 15:21  节日快乐  阅读(91)  评论(0编辑  收藏  举报