mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
增加TemporalAccessorUtil.isIn
This commit is contained in:
parent
8a9025ac55
commit
f2cde9a860
@ -18,6 +18,7 @@
|
|||||||
* 【http 】 优化HttpUtil.isHttp判断,避免NPE(pr#698@Gitee)
|
* 【http 】 优化HttpUtil.isHttp判断,避免NPE(pr#698@Gitee)
|
||||||
* 【core 】 修复Dict#containsKey方法没区分大小写问题(pr#697@Gitee)
|
* 【core 】 修复Dict#containsKey方法没区分大小写问题(pr#697@Gitee)
|
||||||
* 【core 】 增加比较两个LocalDateTime是否为同一天(pr#693@Gitee)
|
* 【core 】 增加比较两个LocalDateTime是否为同一天(pr#693@Gitee)
|
||||||
|
* 【core 】 增加TemporalAccessorUtil.isIn(issue#I5HBL0@Gitee)
|
||||||
*
|
*
|
||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题(pr#2428@Github)
|
* 【core 】 修复CollUtil里面关于可变参数传null造成的crash问题(pr#2428@Github)
|
||||||
|
@ -162,4 +162,22 @@ public class TemporalAccessorUtil extends TemporalUtil{
|
|||||||
|
|
||||||
return result;
|
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…
x
Reference in New Issue
Block a user