OffsetDateTime
是日期时间的表示
抵消。
创建一个OffsetDateTime
,您需要一个区域偏移。
ISO-8601 日历中与 UTC/格林威治有偏移的日期时间
系统,例如 2007-12-03T10:15:30+01:00。
see: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html
例如:
OffsetDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
如果您尝试解析日期时间ZoneId
,你应该使用ZonedDateTime
.
ISO-8601 日历系统中带有时区的日期时间,例如
2007-12-03T10:15:30+01:00 欧洲/巴黎。
see: https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html https://docs.oracle.com/javase/8/docs/api/java/time/ZonedDateTime.html
例如:
ZonedDateTime.parse("2011-12-03T10:15:30", DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.systemDefault()));
如果您需要的是 ISO-8601 日历系统中没有时区的日期时间,您可以使用LocalDateTime
.
ISO-8601 日历系统中没有时区的日期时间,例如
如 2007-12-03T10:15:30。
see: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html
例如:
LocalDateTime.parse("2016-06-24T13:39:44.687680", DateTimeFormatter.ISO_LOCAL_DATE_TIME);