Konvertieren Sie "String" in "java.time.LocalDate"
static final private String DATE_FORMAT = "yyyy-MM-dd";
public static LocalDate string2LocalDate(final String date) {
return LocalDate.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
}
Konvertieren Sie "java.util.Date" in "java.time.LocalDate"
public static LocalDate date2LocalDate(final Date date) {
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
Konvertieren Sie "java.time.LocalDate" in "java.util.Date"
public static Date localDate2Date(final LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
Recommended Posts