chinabugotech/hutool · error · IllegalArgumentException
The date must not be null
Error message
The date must not be null
What it means
Error "The date must not be null" thrown in chinabugotech/hutool.
Source
Thrown at hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java:1702
* @param date2 日期2
* @return 是否为相同时间
* @since 4.1.13
*/
public static boolean isSameTime(Date date1, Date date2) {
return date1.compareTo(date2) == 0;
}
/**
* 比较两个日期是否为同一天
*
* @param date1 日期1
* @param date2 日期2
* @return 是否为同一天
* @since 4.1.13
*/
public static boolean isSameDay(final Date date1, final Date date2) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
return CalendarUtil.isSameDay(calendar(date1), calendar(date2));
}
/**
* 比较两个日期是否为同一周
*
* @param date1 日期1
* @param date2 日期2
* @param isMon 是否为周一。国内第一天为星期一,国外第一天为星期日
* @return 是否为同一周
*/
public static boolean isSameWeek(final Date date1, final Date date2, boolean isMon) {
if (date1 == null || date2 == null) {
throw new IllegalArgumentException("The date must not be null");
}
return CalendarUtil.isSameWeek(calendar(date1), calendar(date2), isMon);
}View on GitHub (pinned to 8870454b2a)
Solutions
- Pass a non-null Date object; check for null before calling the method.
- Use ObjectUtil.defaultIfNull or Optional to supply a default date.
When it happens
Trigger: Thrown at hutool-core/src/main/java/cn/hutool/core/date/DateUtil.java:1702 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chinabugotech/hutool@8870454b2a (2026-08-14).
Data as JSON: /api/errors/f76d26cf4bcfb070.
Report an issue: GitHub.