代码实现:
private Boolean dateEqual(String time) throws ParseException {
//年月日的格式,yyyy-MM-dd,只准确到日
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
//当前时间
Date nowTime = format.parse(format.format(new Date()));
//将输入的时间格式化
Date beginTime = format.parse(time);
int compareTo = nowTime.compareTo(beginTime);
if (compareTo == 0) {
return true;
} else {
return false;
}
}