!693 比较两个 LocalDateTime 是否为同一天

Merge pull request !693 from HsinDumas/v5-dev
This commit is contained in:
Looly 2022-07-16 00:59:02 +00:00 committed by Gitee
commit 7dd7a35edf
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -571,4 +571,16 @@ public class LocalDateTimeUtil {
public static int weekOfYear(TemporalAccessor date){
return TemporalAccessorUtil.get(date, WeekFields.ISO.weekOfYear());
}
/**
* 比较两个日期是否为同一天
*
* @param date1 日期1
* @param date2 日期2
* @return 是否为同一天
* @since 5.8.5
*/
public static boolean isSameDay(final LocalDateTime date1, final LocalDateTime date2) {
return date1 != null && date2 != null && date1.toLocalDate().isEqual(date2.toLocalDate());
}
}