时间工具 threetenbp
package com.fl;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.DateTimeFormatter;
public class Test {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
public static void main(String[] args) {
LocalDate currentDate = LocalDate.parse("2022-05-18");
LocalDate localDate = currentDate.plusDays(30);
System.out.println(localDate);
LocalDate parse1 = LocalDate.parse("20220518", DATE_TIME_FORMATTER);
System.out.println(parse1);
boolean equals = parse1.equals(currentDate);
boolean after = localDate.isAfter(currentDate);
LocalDate minus = currentDate.minusDays(1L);
long l = currentDate.toEpochDay();
System.out.println(currentDate.toEpochDay());
System.out.println(after);
}
}
依赖的包
<!--时间工具-->
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>1.4.5</version>
</dependency>