gpt4 book ai didi

java - 无法解析: Unable to obtain OffsetDateTime from TemporalAccessor:

转载 作者:行者123 更新时间:2023-11-29 04:07:47 26 4
gpt4 key购买 nike

我有这段代码:

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

最佳答案

ZonedDateTime

A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.

LocalDate

A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.

由于您的字符串仅代表简单日期,因此使用 LocalDate

LocalDate date = LocalDate.parse(startTime, DateTimeFormatter.ISO_DATE);

关于java - 无法解析: Unable to obtain OffsetDateTime from TemporalAccessor:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57208670/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com