public class BetweenUtil extends Object
比较工具工具类
用于比较一个给定的值是否在一个指定的范围内,其主要作用如下:Constructor and Description |
---|
BetweenUtil() |
Modifier and Type | Method and Description |
---|---|
static Integer |
get(Integer compareValue,
Integer startValue,
Integer endValue)
判断给定的值是否在边界范围内,如不在边界范围内则返回边界值,若在范围内则返回当前值
|
static Long |
get(Long compareValue,
Long startValue,
Long endValue)
判断给定的值是否在边界范围内,如不在边界范围内则返回边界值,若在范围内则返回当前值
|
static boolean |
isBetween(Date compareValue,
Date startValue,
Date endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isBetween(Double compareValue,
Double startValue,
Double endValue)
判断给定的值是否不在指定的数据范围的区间内
|
static boolean |
isBetween(Float compareValue,
Float startValue,
Float endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isBetween(Integer compareValue,
Integer startValue,
Integer endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isBetween(LocalDateTime compareValue,
LocalDateTime startValue,
LocalDateTime endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isBetween(Long compareValue,
Long startValue,
Long endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isNotBetween(Date compareValue,
Date startValue,
Date endValue)
判断给定的值是否不在指定的数据范围的区间内
|
static boolean |
isNotBetween(Double compareValue,
Double startValue,
Double endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isNotBetween(Float compareValue,
Float startValue,
Float endValue)
判断给定的值是否在指定的数据范围的区间内
|
static boolean |
isNotBetween(Integer compareValue,
Integer startValue,
Integer endValue)
判断给定的值是否不在指定的数据范围的区间内
|
static boolean |
isNotBetween(LocalDateTime compareValue,
LocalDateTime startValue,
LocalDateTime endValue)
判断给定的值是否不在指定的数据范围的区间内
|
static boolean |
isNotBetween(Long compareValue,
Long startValue,
Long endValue)
判断给定的值是否不在指定的数据范围的区间内
|
public static Integer get(Integer compareValue, Integer startValue, Integer endValue)
判断给定的值是否在边界范围内,如不在边界范围内则返回边界值,若在范围内则返回当前值
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为2
例如 compareValue=9,startValue=2 ,endValue=8时的返回值为8
例如 compareValue=4,startValue=2 ,endValue=8时的返回值为4
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static Long get(Long compareValue, Long startValue, Long endValue)
判断给定的值是否在边界范围内,如不在边界范围内则返回边界值,若在范围内则返回当前值
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为2
例如 compareValue=9,startValue=2 ,endValue=8时的返回值为8
例如 compareValue=4,startValue=2 ,endValue=8时的返回值为4
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isBetween(Integer compareValue, Integer startValue, Integer endValue)
判断给定的值是否在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为truecompareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isNotBetween(Integer compareValue, Integer startValue, Integer endValue)
判断给定的值是否不在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为false
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为true
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isBetween(Long compareValue, Long startValue, Long endValue)
判断给定的值是否在指定的数据范围的区间内
注意:包含边界 例如 compareValue=2,startValue=2 ,endValue=8时的返回值为truecompareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isNotBetween(Long compareValue, Long startValue, Long endValue)
判断给定的值是否不在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为false
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为true
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isBetween(Float compareValue, Float startValue, Float endValue)
判断给定的值是否在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为truecompareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isNotBetween(Float compareValue, Float startValue, Float endValue)
判断给定的值是否在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为false
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为true
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isBetween(Double compareValue, Double startValue, Double endValue)
判断给定的值是否不在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为truecompareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isNotBetween(Double compareValue, Double startValue, Double endValue)
判断给定的值是否在指定的数据范围的区间内
注意:包含边界
例如 compareValue=2,startValue=2 ,endValue=8时的返回值为false
例如 compareValue=1,startValue=2 ,endValue=8时的返回值为true
compareValue
- 给定的值,如果给定的值为null,则默认替换为0startValue
- 比较范围的开始值,如果给定的值为null,则默认替换为0endValue
- 比较范围的结束值,如果给定的值为null,则默认替换为0public static boolean isBetween(Date compareValue, Date startValue, Date endValue)
判断给定的值是否在指定的数据范围的区间内
注意:
1. 不包含边界
2. 任意一个值为null则返回值为false
例如 compareValue=2020-12-12 12:12:12,startValue=2020-12-12 12:12:12 ,endValue=2021-12-12 12:12:12时的返回值为true
例如 compareValue=2020-12-11 12:12:12,startValue=2020-12-12 12:12:12 ,endValue=2021-12-12 12:12:12时的返回值为false
compareValue
- 给定的值startValue
- 比较范围的开始值endValue
- 比较范围的结束值public static boolean isNotBetween(Date compareValue, Date startValue, Date endValue)
判断给定的值是否不在指定的数据范围的区间内
1. 包含边界
2. 任意一个值为null则返回值为truecompareValue
- 给定的值startValue
- 比较范围的开始值endValue
- 比较范围的结束值public static boolean isBetween(LocalDateTime compareValue, LocalDateTime startValue, LocalDateTime endValue)
判断给定的值是否在指定的数据范围的区间内
注意:
1. 包含边界
2. 任意一个值为null则返回值为false例如 compareValue=2020-12-12 12:12:12,startValue=2020-12-12 12:12:12 ,endValue=2021-12-12 12:12:12时的返回值为true
例如 compareValue=2020-12-11 12:12:12,startValue=2020-12-12 12:12:12 ,endValue=2021-12-12 12:12:12时的返回值为false
compareValue
- 给定的值startValue
- 比较范围的开始值endValue
- 比较范围的结束值public static boolean isNotBetween(LocalDateTime compareValue, LocalDateTime startValue, LocalDateTime endValue)
判断给定的值是否不在指定的数据范围的区间内
1. 包含边界
2. 任意一个值为null则返回值为falsecompareValue
- 给定的值startValue
- 比较范围的开始值endValue
- 比较范围的结束值Copyright © 2021. All rights reserved.