解析日期时间时出错,带有有效时间戳的 DateTimeParseException

Error parsing datetime, DateTimeParseException with valid timestamp

我正在尝试从 sql 解析时间戳对象,但遇到了问题,这是我所拥有的:

 DateTimeFormatter dateDTF = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);


 String start = c.getStartTime().getValue();
 //Start: 2018-12-01 16:00:00
 System.out.println("Start: " + start);
 LocalDateTime startDatetime = LocalDateTime.parse(start, dateDTF);

正如您在注释代码中看到的那样,我的 start 到 trim 的值在我的工作 example.I 中出现以下错误:

java.time.format.DateTimeParseException: Text '2018-12-01 16:00:00' could not be parsed at index 4

使用

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

此处指定DateTimeFormat

模式