20230630 java.time.LocalTime
介绍
- java.time.LocalTime
- 类声明
@jdk.internal.ValueBased
public final class LocalTime implements Temporal, TemporalAdjuster, Comparable<LocalTime>, Serializable
-
本地时间
-
plus
和minus
操作是按照一天 24 小时循环操作的 -
实现
Temporal
,支持的时间单位(TemporalUnit
)有- NANOS
- MICROS
- MILLIS
- SECONDS
- MINUTES
- HOURS
- HALF_DAYS
-
实现
TemporalAccessor
,支持的时间域(TemporalField
)有- NANO_OF_SECOND
- NANO_OF_DAY
- MICRO_OF_SECOND
- MICRO_OF_DAY
- MILLI_OF_SECOND
- MILLI_OF_DAY
- SECOND_OF_MINUTE
- SECOND_OF_DAY
- MINUTE_OF_HOUR
- MINUTE_OF_DAY
- HOUR_OF_AMPM
- CLOCK_HOUR_OF_AMPM
- HOUR_OF_DAY
- CLOCK_HOUR_OF_DAY
- AMPM_OF_DAY
-
内部存储是
private final byte hour;
private final byte minute;
private final byte second;
private final int nano;
API
常量
- MIN : 00:00
- MAX : 23:59:59.999999999
- MIDNIGHT : 00:00
- NOON : 12:00
static
- now
- of
- ofInstant
- ofSecondOfDay
- ofNanoOfDay
- from
LocalTime from(TemporalAccessor temporal)
- parse
- 反
toString
- 格式示例:
10:15:30
- 反
public
- truncatedTo
- format
- isAfter
- isBefore
get
- getHour
- getMinute
- getSecond
- getNano
with
- withHour
- withMinute
- withSecond
- withNano
plus/minus
- plusHours
- plusMinutes
- plusSeconds
- plusNanos
- minusHours
- minusMinutes
- minusSeconds
- minusNanos
at
- atDate
- atOffset
to
- toSecondOfDay
- toNanoOfDay
- toEpochSecond