基于Hutool 判断 日期是否 跨日,月,天
DateTime startDate = DateUtil.parseDateTime(startTime);
DateTime endDate = DateUtil.parseDateTime(endTime);
LocalDateTime endOfDay = LocalDateTimeUtil.endOfDay(endDate.toLocalDateTime());
if (startDate.isAfter(endDate)) {
return JsonResult.getFailResult(" 结束日期不能小于开始日期");
}
boolean isCrossYear = startDate.getYear() != endDate.getYear();
boolean isCrossMonth = startDate.getMonth() != endDate.getMonth();
boolean isCrossDay = startDate.getDay() != endDate.getDay();
long diffDays = DateUtil.betweenDay(startDate, endDate, true);
int diffMonths = DateUtils.calculateMonthDifference(startDate, endDate);
long diffYears = DateUtil.betweenYear(startDate, endDate, true);