1 /** 2 * 判断日期是否和(today日期的差)相同 3 * 4 * @param date 5 * @param dateNum 6 * today日期的差 ;1表示明天,0表示今天,-1表示昨天,-2表示前天,以此类推 7 * @return 8 */ 9 public static boolean isToday4Num(final Date date, int dateNum) { 10 if (date == null) { 11 throw new IllegalArgumentException("The date must not be null"); 12 } 13 final Calendar cal1 = Calendar.getInstance(); 14 cal1.setTime(date); 15 final Calendar cal2 = Calendar.getInstance(); 16 cal2.add(Calendar.DAY_OF_YEAR, dateNum); 17 return org.apache.commons.lang.time.DateUtils.isSameDay(cal1, cal2); 18 }