mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
增加TemporalAccessorUtil.isIn
This commit is contained in:
parent
8a9025ac55
commit
f2cde9a860
@ -18,6 +18,7 @@
|
||||
* 【http 】 优化HttpUtil.isHttp判断,避免NPE(pr#698@Gitee)
|
||||
* 【core 】 修复Dict#containsKey方法没区分大小写问题(pr#697@Gitee)
|
||||
* 【core 】 增加比较两个LocalDateTime是否为同一天(pr#693@Gitee)
|
||||
* 【core 】 增加TemporalAccessorUtil.isIn(issue#I5HBL0@Gitee)
|
||||
*
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题(pr#2428@Github)
|
||||
|
@ -162,4 +162,22 @@ public class TemporalAccessorUtil extends TemporalUtil{
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前日期是否在日期指定范围内<br>
|
||||
* 起始日期和结束日期可以互换
|
||||
*
|
||||
* @param date 被检查的日期
|
||||
* @param beginDate 起始日期(包含)
|
||||
* @param endDate 结束日期(包含)
|
||||
* @return 是否在范围内
|
||||
* @since 5.8.5
|
||||
*/
|
||||
public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate){
|
||||
final long thisMills = toEpochMilli(date);
|
||||
final long beginMills = toEpochMilli(beginDate);
|
||||
final long endMills = toEpochMilli(endDate);
|
||||
|
||||
return thisMills >= Math.min(beginMills, endMills) && thisMills <= Math.max(beginMills, endMills);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user