class DateTimeRound extends Object
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
private static List<ChronoUnit> |
SUPPORTED_UNITS_FOR_ROUND |
Supported units for
round methods. |
private static String |
SUPPORTED_UNITS_FOR_ROUND_STRING |
|
private static List<ChronoUnit> |
SUPPORTED_UNITS_FOR_ROUND_TIME |
Supported units for
roundTime methods. |
private static String |
SUPPORTED_UNITS_FOR_ROUND_TIME_STRING |
| 构造器 | 说明 |
|---|---|
DateTimeRound() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
private static void |
checkValidAmountUnit(ChronoUnit chronoUnit,
int amountUnit) |
根据指定的 ChronoUnit 校验 amountUnit 的值是否合法
|
private static int |
halfUp(int value) |
获取需要向上取整的最小值
|
private static int |
halfUpDay(int daysOfMonth) |
获取需要向上取整的最小天数
|
static LocalDateTime |
round(LocalDateTime localDateTime,
ChronoUnit chronoUnit,
RoundingDT roundingDT) |
对时间进行取整
|
static Calendar |
round(Calendar calendar,
ChronoUnit chronoUnit,
RoundingDT roundingDT) |
对时间进行取整
|
static Date |
round(Date date,
ChronoUnit chronoUnit,
RoundingDT roundingDT) |
对时间进行取整
|
static <T extends Temporal> |
round(T temporal,
LocalDateTime localDateTime,
ZoneId zoneId,
ChronoUnit chronoUnit,
RoundingDT roundingDT) |
对时间进行取整
|
static LocalDateTime |
roundTime(LocalDateTime localDateTime,
ChronoUnit chronoUnit,
int amountUnit,
RoundingDT roundingDT) |
对时间的 时,分,秒 进行取整。
|
static Calendar |
roundTime(Calendar calendar,
ChronoUnit chronoUnit,
int amountUnit,
RoundingDT roundingDT) |
对时间的 时,分,秒 进行取整。
|
static Date |
roundTime(Date date,
ChronoUnit chronoUnit,
int amountUnit,
RoundingDT roundingDT) |
对时间的 时,分,秒 进行取整。
|
static <T extends Temporal> |
roundTime(T temporal,
LocalDateTime localDateTime,
ZoneId zoneId,
ChronoUnit chronoUnit,
int amountUnit,
RoundingDT roundingDT) |
对时间进行取整
|
private static final List<ChronoUnit> SUPPORTED_UNITS_FOR_ROUND
round methods.private static final String SUPPORTED_UNITS_FOR_ROUND_STRING
private static final List<ChronoUnit> SUPPORTED_UNITS_FOR_ROUND_TIME
roundTime methods.private static final String SUPPORTED_UNITS_FOR_ROUND_TIME_STRING
public static LocalDateTime round(LocalDateTime localDateTime, ChronoUnit chronoUnit, RoundingDT roundingDT)
localDateTime - 时间chronoUnit - 按此时间单位作为取整后的精度roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static <T extends Temporal> T round(T temporal, LocalDateTime localDateTime, ZoneId zoneId, ChronoUnit chronoUnit, RoundingDT roundingDT)
T - 时间类型,若类型为 Instant,则以 TZ.DEFAULT_ZONE 时区为准,进行取整运算。temporal - 时间localDateTime - localDateTimezoneId - 时区chronoUnit - 按此时间单位作为取整后的精度roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static Date round(Date date, ChronoUnit chronoUnit, RoundingDT roundingDT)
date - 时间chronoUnit - 按此时间单位作为取整后的精度roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static Calendar round(Calendar calendar, ChronoUnit chronoUnit, RoundingDT roundingDT)
calendar - 时间chronoUnit - 按此时间单位作为取整后的精度roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static Calendar roundTime(Calendar calendar, ChronoUnit chronoUnit, int amountUnit, RoundingDT roundingDT)
calendar - calendarchronoUnit - 时间取整的精度amountUnit - 时间步长roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static Date roundTime(Date date, ChronoUnit chronoUnit, int amountUnit, RoundingDT roundingDT)
date - datechronoUnit - 时间取整的精度amountUnit - 时间步长roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static LocalDateTime roundTime(LocalDateTime localDateTime, ChronoUnit chronoUnit, int amountUnit, RoundingDT roundingDT)
localDateTime - localDateTimechronoUnit - 时间取整的精度amountUnit - 时间步长roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORpublic static <T extends Temporal> T roundTime(T temporal, LocalDateTime localDateTime, ZoneId zoneId, ChronoUnit chronoUnit, int amountUnit, RoundingDT roundingDT)
T - 时间类型,若类型为 Instant,则以 TZ.DEFAULT_ZONE 时区为准,进行取整运算。temporal - 时间localDateTime - localDateTimezoneId - 时区chronoUnit - 按此时间单位作为取整后的精度amountUnit - 时间步长roundingDT - 取整类型,值为null默认为:RoundingDT.FLOORprivate static void checkValidAmountUnit(ChronoUnit chronoUnit, int amountUnit)
chronoUnit - 时间单位amountUnit - 时间步长private static int halfUpDay(int daysOfMonth)
daysOfMonth - 当前月份的总天数private static int halfUp(int value)
value - 待计算的值Copyright © 2023. All rights reserved.