/**
* 时间差值校验
*
* @param dates 时间数组
* @return 对比结果
*/
private Boolean checkMonth(Date… dates) {
if (dates.length > 1) {
for (int i = 0; i < dates.length; i++) {
for (int j = 1; j < dates.length; j++) {
Boolean month = getMonth(dates[i], dates[j]);
if (month) {
return Boolean.TRUE;
}
}
}
}
return Boolean.FALSE;
}
/**
* 计算两个时间相差是否在3个月内
*
* @param start 开始时间
* @param end 结束时间
* @return 对比结果true是在3个月内,false为不在3个月内
*/
private Boolean getMonth(Date start, Date end) {
if (start.after(end)) {
Date t = start;
start = end;
end = t;
}
Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(start);
c2.setTime(end);
c1.add(Calendar.MONTH, 3);
if (c1.getTimeInMillis() <= c2.getTimeInMillis()) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}