无法解析:无法从TemporalAccessor获取OffsetDateTime: [英] could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor:
本文介绍了无法解析:无法从TemporalAccessor获取OffsetDateTime:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这段代码:
public static final String DATE_PATTERN = "yyyy-MM-dd";
OffsetDateTime.parse(startTime, DateTimeFormatter.ofPattern(DateFormat.DATE_PATTERN)
但解析时出现此错误:
java.time.format.DateTimeParseException: Text '2019-07-10' could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor: {},ISO resolved to 2019-07-10 of type java.time.format.Parsed
推荐答案
ISO-8601日历系统中带有时区的日期时间,例如2007-12-03T10:15:30 + 01:00欧洲/巴黎.
A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.
ISO-8601日历系统中没有时区的日期,例如2007-12-03.
A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.
由于您的字符串仅表示简单日期,因此请使用LocalDate
Since your string just represents simple date, so use LocalDate
LocalDate date = LocalDate.parse(startTime, DateTimeFormatter.ISO_DATE);
这篇关于无法解析:无法从TemporalAccessor获取OffsetDateTime:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文