如何从 Temporal 获取 TimeZone?

How to get TimeZone from Temporal?

interface SomeDataClass {
  TemporalAccessor getSomeTime();
}

//somewhere in the impl...
public TemporalAccessor getSomeTime() {
  return OffsetDateTime.from(dateTimeFormatter.parse(someDateInstring));
}

有谁知道如何从这个TemporalAccessor界面获取时区数据?

如果您需要 ZoneOffsetZoneId,您可以从 TemporalAccessor:

创建它
TemporalAccessor acc = ZonedDateTime.now();
System.out.println(ZoneOffset.from(acc));
System.out.println(ZoneId.from(acc));