📜  java中的日期格式 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:53.204000             🧑  作者: Mango

代码示例4
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

try {
    LocalDate date = formatter.parse(text, LocalDate::from);
} catch (DateTimeParseException e) {
    // Thrown if text could not be parsed in the specified format
}