比较日期是不是在某个时间范围内:
/*
* 校验Bom最新版本时间是不是在筛选条件范围内
* 结束时间为空,则结束时间为当前时间
*/
public static boolean checkDate(Date nowTime, Date startDate, Date endDate) {
if(null == startDate && null == endDate){
return true;
}else if(null != startDate && null != endDate){
if (nowTime.after(startDate) && nowTime.before(endDate)) {
return true;
}else if(nowTime.compareTo(startDate) ==0 || nowTime.compareTo(endDate) == 0 ){
return true;
}else {
return false;
}
}else if(null != startDate && null ==endDate){
endDate = new Date();
if (nowTime.after(startDate) && nowTime.before(endDate)) {
return true;
}else if(nowTime.compareTo(startDate)==0 || nowTime.compareTo(endDate) == 0 ){
return true;
}else {
return false;
}
}else if(null == startDate && null != endDate){
if(nowTime.compareTo(endDate) == 0){
return true;
}else{
return false;
}
}else{
return false;
}
}
网友评论