Convert String
to 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));
}
Convert java.util.Date
to java.time.LocalDate
public static LocalDate date2LocalDate(final Date date) {
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
Convert java.time.LocalDate
to java.util.Date
public static Date localDate2Date(final LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
Recommended Posts