diff --git a/CHANGELOG.md b/CHANGELOG.md index e39f76b03..b739726d5 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * 【core 】 ForestMap添加getNodeValue方法(pr#699@Gitee) * 【http 】 优化HttpUtil.isHttp判断,避免NPE(pr#698@Gitee) * 【core 】 修复Dict#containsKey方法没区分大小写问题(pr#697@Gitee) +* 【core 】 增加比较两个LocalDateTime是否为同一天(pr#693@Gitee) * ### 🐞Bug修复 * 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题(pr#2428@Github) diff --git a/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java b/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java index ae26cb662..65349133e 100755 --- a/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/date/LocalDateTimeUtil.java @@ -581,6 +581,18 @@ public class LocalDateTimeUtil { * @since 5.8.5 */ public static boolean isSameDay(final LocalDateTime date1, final LocalDateTime date2) { - return date1 != null && date2 != null && date1.toLocalDate().isEqual(date2.toLocalDate()); + return date1 != null && date2 != null && isSameDay(date1.toLocalDate(), date2.toLocalDate()); + } + + /** + * 比较两个日期是否为同一天 + * + * @param date1 日期1 + * @param date2 日期2 + * @return 是否为同一天 + * @since 5.8.5 + */ + public static boolean isSameDay(final LocalDate date1, final LocalDate date2) { + return date1 != null && date2 != null && date1.isEqual(date2); } }