Modifier and Type | Method | Description |
---|---|---|
static LocalDateTime | now() | 返回当前系统的日期和时间 |
Modifier and Type | Method | Description |
---|---|---|
static LocalDateTime | of(int year, int month, int dayOfMonth, int hour, int minute) | 按照给定的参数设置日期和时间,秒、毫秒默认设置为0 |
static LocalDateTime | of(int year, int month, int dayOfMonth, int hour, int minute, int second) | 按照给定的参数设置日期和时间,毫秒默认设置为0 |
static LocalDateTime | of(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) | 按照给定的参数设置日期和时间 |
static LocalDateTime | of(LocalDate date, LocalTime time) | 按照给定的参数设置日期和时间 |
Modifier and Type | Method | Description |
---|---|---|
static LocalDateTime | parse(CharSequence text, DateTimeFormatter formatter) | 用指定格式的字符串构造一个日期和时间对象 |
Modifier and Type | Method | Description |
---|---|---|
LocalDate | toLocalDate() | 返回当前日期和时间对象的日期部分 |
LocalTime | toLocalTime() | 返回当前日期和时间对象的时间部分 |
Modifier and Type | Method | Description |
---|---|---|
int | getNano() | 获取当前日期和时间对象的毫秒数 |
int | getSecond() | 获取当前日期和时间对象的秒数 |
int | getMinute() | 获取当前日期和时间对象的分钟数 |
int | getHour() | 获取当前日期和时间对象的小时数 |
int | getDayOfMonth() | 返回当前日期和时间对象是一个月中的第几天 |
int | getDayOfYear() | 返回当前日期和时间对象是一年中的第几天 |
int | getMonthValue() | 获取当前日期和时间对象的月份数 |
int | getYear() | 获取当前日期和时间对象的年份数 |
Modifier and Type | Method | Description |
---|---|---|
String | format(DateTimeFormatter formatter) | 按照指定格式返回当前日期和时间对象对应的字符串 |
Modifier and Type | Method | Description |
---|---|---|
LocalDateTime | plusNanos(long nanos) | 将当前日期和时间对象增加指定的毫秒数 |
LocalDateTime | plusSeconds(long seconds) | 将当前日期和时间对象增加指定的秒数 |
LocalDateTime | plusMinutes(long minutes) | 将当前日期和时间对象增加指定的分钟数 |
LocalDateTime | plusHours(long hours) | 将当前日期和时间对象增加指定的小时数 |
LocalDateTime | plusDays(long days) | 将当前日期和时间对象增加指定的天数 |
LocalDateTime | plusWeeks(long weeks) | 将当前日期和时间对象增加指定的星期数 |
LocalDateTime | plusMonths(long months) | 将当前日期和时间对象增加指定的月份数 |
LocalDateTime | plusYears(long years) | 将当前日期和时间对象增加指定的年份数 |
Modifier and Type | Method | Description |
---|---|---|
LocalDateTime | minusNanos(long nanos) | 将当前日期和时间对象减少指定的毫秒数 |
LocalDateTime | minusSeconds(long seconds) | 将当前日期和时间对象减少指定的秒数 |
LocalDateTime | minusMinutes(long minutes) | 将当前日期和时间对象减少指定的分钟数 |
LocalDateTime | minusHours(long hours) | 将当前日期和时间对象减少指定的小时数 |
LocalDateTime | minusDays(long days) | 将当前日期和时间对象减少指定的天数 |
LocalDateTime | minusWeeks(long weeks) | 将当前日期和时间对象减少指定的星期数 |
LocalDateTime | minusMonths(long months) | 将当前日期和时间对象减少指定的月份数 |
LocalDateTime | minusYears(long years) | 将当前日期和时间对象减少指定的年份数 |
Modifier and Type | Method | Description |
---|---|---|
LocalDateTime | withNano(int nanoOfSecond) | 将当前日期和时间对象的毫秒调整为指定值 |
LocalDateTime | withSecond(int second) | 将当前日期和时间对象的秒调整为指定值 |
LocalDateTime | withMinute(int minute) | 将当前日期和时间对象的分钟调整为指定值 |
LocalDateTime | withHour(int hour) | 将当前日期和时间对象的小时调整为指定值 |
LocalDateTime | withDayOfMonth(int dayOfMonth) | 修改一个月中的第几天为指定值 |
LocalDateTime | withDayOfYear(int dayOfYear) | 修改一年中的第几天为指定值 |
LocalDateTime | withMonth(int month) | 将当前日期和时间对象的月份调整为指定值 |
LocalDateTime | withYear(int year) | 将当前日期和时间对象的年份调整为指定值 |
Modifier and Type | Method | Description |
---|---|---|
boolean | isAfter(ChronoLocalDateTime<?> other) | 判断当前日期和时间对象是否在给定日期和时间对象之后。如果是则返回true |
boolean | isBefore(ChronoLocalDateTime<?> other) | 判断当前日期和时间对象是否在给定日期和时间对象之前。如果是则返回true |