2019独角兽企业重金招聘Python工程师标准>>>
pom
<dependency><groupId>commons-lang</groupId><artifactId>commons-lang</artifactId><version>2.6</version>
</dependency>
/*** 判断日期是否和(today日期的差)相同* * @param date* @param dateNum* today日期的差 ;1表示明天,0表示今天,-1表示昨天,-2表示前天,以此类推* @return* @author <a href="http://git.oschina.net/denger"> 羊登琼 </a>*/public boolean isToday4Num(final Date date, int dateNum) {if (date == null) {throw new IllegalArgumentException("The date must not be null");}final Calendar cal1 = Calendar.getInstance();cal1.setTime(date);final Calendar cal2 = Calendar.getInstance();cal2.add(Calendar.DAY_OF_YEAR, dateNum);return org.apache.commons.lang.time.DateUtils.isSameDay(cal1, cal2);}
代码很小量,也没什么技术含量,记录下来避免重复造轮子费时间。点滴汇海