我有以下代码:
String dateTimeInStr = "17-Jul-2020 12:12";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MMM-YYYY HH:mm");
// OffsetDateTime offsetDateTime = OffsetDateTime.parse(dateTimeInStr, formatter);
LocalDateTime localDateTime = LocalDateTime.parse(dateTimeInStr, formatter);
System.out.println(localDateTime);
// System.out.println(offsetDateTime);
如您所见,我尝试将字符串 17-Jul-2020 12:12 转换为 LocalDateTime 或 OffsetDateTime。但没有任何效果。
Text '17-Jul-2020 12:12' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {WeekBasedYear[WeekFields[MONDAY,1]]=2020, MonthOfYear=7, DayOfMonth=17},ISO resolved to 12:12 of type java.time.format.Parsed
有谁知道如何解决这个问题?提前致谢。