当前时间
LocalDateTime.now()
2019-03-31T14:48:06.699
LocalDate.now()
2019-03-31
LocalTime.now()
14:48:06.699
ZonedDateTime.now()
2019-03-31T14:48:06.699+08:00[Asia/Shanghai]
Instant.now()
2019-03-31T06:49:41.329Z
年月日时分秒
LocalDateTime.now().year
LocalDateTime.now().month.value
LocalDateTime.now().monthValue
LocalDateTime.now().dayOfMonth
LocalDateTime.now().hour
LocalDateTime.now().minute
LocalDateTime.now().second
星期
LocalDateTime.now().dayOfWeek
LocalDateTime.now().dayOfWeek.value
切换日期
LocalDateTime.now().withMonth(Month.OCTOBER.value)
LocalDateTime.now().plusWeeks(1)
LocalDate.now().minusDays(-1)
LocalDate.now().plus(2, ChronoUnit.DAYS)
月份的最大最小天数
LocalDate.now().range(ChronoField.DAY_OF_MONTH).minimum
LocalDate.now().range(ChronoField.DAY_OF_MONTH).maximum
闰年
Year.of(2019).isLeap
LocalDate.now().isLeapYear
调整日期
LocalDate.now().with(TemporalAdjusters.next(DayOfWeek.SUNDAY))
LocalDate.now().with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY))
LocalDate.now().with(TemporalAdjusters.firstDayOfNextYear())
LocalDate.now().with(TemporalAdjusters.firstDayOfYear())
LocalDate.now().with(TemporalAdjusters.lastDayOfMonth())
LocalDate.of(2019, 5, 1).with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.SUNDAY))
LocalDate.of(2019, 6, 1).with(TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.SUNDAY))
LocalDate.now().with(TemporalAdjusters.firstInMonth(DayOfWeek.SUNDAY))
LocalDate.now().with(TemporalAdjusters.dayOfWeekInMonth(1, DayOfWeek.SUNDAY))
LocalDate.now().with(TemporalAdjusters.dayOfWeekInMonth(0, DayOfWeek.SUNDAY))
其他
MonthDay.now()
--03-31
YearMonth.now()
2019-03
Year.now()
2019
毫秒
ZonedDateTime.now().toInstant().toEpochMilli()
OffsetDateTime.now().toInstant().toEpochMilli()
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()