20230522 java.time.LocalDate
介绍
java.time.LocalDate
- 类声明
@jdk.internal.ValueBased
public final class LocalDate implements Temporal, TemporalAdjuster, ChronoLocalDate, Serializable
- 本地日期
- 实现
Temporal
,支持的时间单位(TemporalUnit
)有- DAYS
- WEEKS
- MONTHS
- YEARS
- DECADES
- 10年
- CENTURIES
- 100年
- MILLENNIA
- 1000年
- ERAS
- 时代,10亿年
- 实现
TemporalAccessor
,支持的时间域(TemporalField
)有- DAY_OF_WEEK
- ALIGNED_DAY_OF_WEEK_IN_MONTH
- ALIGNED_DAY_OF_WEEK_IN_YEAR
- DAY_OF_MONTH
- DAY_OF_YEAR
- EPOCH_DAY
- ALIGNED_WEEK_OF_MONTH
- ALIGNED_WEEK_OF_YEAR
- MONTH_OF_YEAR
- PROLEPTIC_MONTH
- YEAR_OF_ERA
- YEAR
- ERA
- 内部存储是
private final int year;
private final short month;
private final short day;
API
常量
- MIN : -999999999-01-01
- MAX : +999999999-12-31
- EPOCH : 1970-01-01
static
- now
- of
LocalDate of(int year, Month month, int dayOfMonth
LocalDate of(int year, int month, int dayOfMonth)
- year : 2023 表示 2023年
- month : 1-12
- dayOfMonth : 1-31
- ofYearDay
LocalDate ofYearDay(int year, int dayOfYear)
- ofInstant
LocalDate ofInstant(Instant instant, ZoneId zone)
- ofEpochDay
- 反
toEpochDay
- 大纪元日第 0 天是 1970-01-01 (ISO)
- 反
- from
LocalDate from(TemporalAccessor temporal)
- parse
- 反
toString
- 格式示例:
2023-06-30
- 反
public
-
toEpochSecond
-
datesUntil
Stream<LocalDate> datesUntil(LocalDate endExclusive)
Stream<LocalDate> datesUntil(LocalDate endExclusive, Period step)
-
toString
- ISO-8601 格式 uuuu-MM-dd
get
- getYear
- getMonthValue
- getMonth
- getDayOfMonth
- getDayOfYear
- getDayOfWeek
plus
- plusYears
- plusMonths
- plusWeeks
- plusDays
- minusYears
- minusMonths
- minusWeeks
- minusDays
with
with:在复制对象的基础上修改
- withYear
- withMonth
- withDayOfMonth
- withDayOfYear
at
at:结合入参形成新类型
- atTime
LocalDateTime atTime(int hour, int minute)
LocalDateTime atTime(int hour, int minute, int second)
LocalDateTime atTime(int hour, int minute, int second, int nanoOfSecond)
OffsetDateTime atTime(OffsetTime time)
- atStartOfDay
LocalDateTime atStartOfDay()
ZonedDateTime atStartOfDay(ZoneId zone)