public class TemporalAccessorUtil extends TemporalUtil
TemporalAccessor
工具类封装Constructor and Description |
---|
TemporalAccessorUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
format(TemporalAccessor time,
DateTimeFormatter formatter)
|
static String |
format(TemporalAccessor time,
String format)
|
static int |
get(TemporalAccessor temporalAccessor,
TemporalField field)
|
static boolean |
isIn(TemporalAccessor date,
TemporalAccessor beginDate,
TemporalAccessor endDate)
当前日期是否在日期指定范围内
起始日期和结束日期可以互换 |
static boolean |
isIn(TemporalAccessor date,
TemporalAccessor beginDate,
TemporalAccessor endDate,
boolean includeBegin,
boolean includeEnd)
当前日期是否在日期指定范围内
起始日期和结束日期可以互换 通过includeBegin, includeEnd参数控制日期范围区间是否为开区间,例如:传入参数:includeBegin=true, includeEnd=false, 则本方法会判断 date ∈ (beginDate, endDate] 是否成立 |
static long |
toEpochMilli(TemporalAccessor temporalAccessor)
|
static Instant |
toInstant(TemporalAccessor temporalAccessor)
TemporalAccessor 转换为 Instant 对象 |
between, between, offset, offset, toChronoUnit, toTimeUnit
public static int get(TemporalAccessor temporalAccessor, TemporalField field)
temporalAccessor
- 需要获取的时间对象field
- 需要获取的属性public static String format(TemporalAccessor time, DateTimeFormatter formatter)
time
- TemporalAccessor
formatter
- 日期格式化器,预定义的格式见:DateTimeFormatter
public static String format(TemporalAccessor time, String format)
time
- TemporalAccessor
format
- 日期格式public static long toEpochMilli(TemporalAccessor temporalAccessor)
temporalAccessor
- Date对象Instant
对象public static Instant toInstant(TemporalAccessor temporalAccessor)
TemporalAccessor
转换为 Instant
对象temporalAccessor
- Date对象Instant
对象public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate)
date
- 被检查的日期beginDate
- 起始日期(包含)endDate
- 结束日期(包含)public static boolean isIn(TemporalAccessor date, TemporalAccessor beginDate, TemporalAccessor endDate, boolean includeBegin, boolean includeEnd)
date
- 被检查的日期beginDate
- 起始日期endDate
- 结束日期includeBegin
- 时间范围是否包含起始日期includeEnd
- 时间范围是否包含结束日期Copyright © 2024. All rights reserved.