我正在尝试将此日期转换为不同的格式。不幸的是还没有成功解析日期并正确保留所有信息。
2017 年 12 月 6 日 07:14:56.656PM 至 2017-12-06 19:14:56.656
如果我尝试解析输入日期
LocalDateTime.parse("06-Dec-2017 07:14:56.656PM",
DateTimeFormatter.ofPattern("D-MMM-yyyy HH:mm:ss.SSSa"));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误 - 不确定这是什么意思?
Exception in thread "main" java.time.format.DateTimeParseException: Text '06-Dec-2017 07:14:56.656PM' could not be parsed: Conflict found: Field MonthOfYear 1 differs from MonthOfYear 12 derived from 2017-01-06
at java.time.format.DateTimeFormatter.createError(Unknown Source)
at java.time.format.DateTimeFormatter.parse(Unknown Source)
at java.time.LocalDateTime.parse(Unknown Source)
at com.cordys.coe.alf.logger.DBLogger.main(DBLogger.java:366)
Caused by: java.time.DateTimeException: Conflict found: Field MonthOfYear 1 differs from MonthOfYear 12 derived from 2017-01-06
at java.time.format.Parsed.crossCheck(Unknown Source)
at java.time.format.Parsed.crossCheck(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
如果尝试
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS")
.format((new …Run Code Online (Sandbox Code Playgroud)