DateUtil(比较两个日期是否是同一天)

1、比较两个日期是否是同一天

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date lastRecordTimeD = sdf.parse(lines[2]);

Calendar lastRecordTimeCal = new GregorianCalendar();

lastRecordTimeCal.setTime(lastRecordTimeD);

Calendar nowTime = Calendar.getInstance();

Calendar tempDate = (Calendar) nowTime.clone();

tempDate.set(Calendar.YEAR, lastRecordTimeCal.get(Calendar.YEAR));
tempDate.set(Calendar.MONTH, lastRecordTimeCal.get(Calendar.MONTH));
tempDate.set(Calendar.DAY_OF_MONTH,lastRecordTimeCal.get(Calendar.DAY_OF_MONTH));

//是否是同一天
boolean sameDay = false;

if (nowTime.equals(tempDate)) {
    sameDay = true;
}
这个博客主要是javaEE相关或者不相关的记录, hadoop与spark的相关文章我写在下面地址的博客啦~ http://www.cnblogs.com/sorco
原文地址:https://www.cnblogs.com/orco/p/6223183.html