1
0
mirror of https://gitee.com/dromara/hutool.git synced 2025-04-05 17:37:59 +08:00

增加比较两个LocalDateTime是否为同一天

This commit is contained in:
Looly 2022-07-16 09:03:12 +08:00
parent 7dd7a35edf
commit 9676a663c3
2 changed files with 14 additions and 1 deletions
CHANGELOG.md
hutool-core/src/main/java/cn/hutool/core/date

View File

@ -17,6 +17,7 @@
* 【core 】 ForestMap添加getNodeValue方法pr#699@Gitee
* 【http 】 优化HttpUtil.isHttp判断避免NPEpr#698@Gitee
* 【core 】 修复Dict#containsKey方法没区分大小写问题pr#697@Gitee
* 【core 】 增加比较两个LocalDateTime是否为同一天pr#693@Gitee
*
### 🐞Bug修复
* 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题pr#2428@Github

View File

@ -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);
}
}