private static final DateTimeFormatter SECOND_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 解析字符串为日期 String dateStr = "1990-01-01"; LocalDate dateTime = LocalDate.parse(dateStr, DAY_FORMATTER);
参考:https://blog.csdn.net/qq_45871274/article/details/134182151