mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
增加TemporalAccessorUtil.isIn
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user