java 时间比较

判断一个时间加30天是否比当前时间大,代码如下:

//repTaskResult.getStartDate()  2024-6-1
//new Date()  2024-6-5
Calendar calendar=Calendar.getInstance();
calendar.setTime(repTaskResult.getStartDate());
calendar.add(Calendar.MONTH,1);
Date startDate30=calendar.getTime();
Date currentDate=new Date();
int result=currentDate.compareTo(startDate30);
if(result< 0){
    map.put("startDate30IsDownload","1");
}
posted @ 2024-07-29 15:47  小海葵  阅读(6)  评论(0编辑  收藏  举报