直接上代码
import cn.hutool.core.date.DateUtil; import java.time.LocalDate; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Date; public class DateUtils extends DateUtil { /** * LocalDate转Date * @param localDate * @return */ public static Date localDate2Date(LocalDate localDate) { if (null == localDate) { return null; } ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); return Date.from(zonedDateTime.toInstant()); } /** * Date转LocalDate * @param date */ public static LocalDate date2LocalDate(Date date) { if(null == date) { return null; } return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); } }