1
interface SomeDataClass {
  TemporalAccessor getSomeTime();
}

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

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

4

1 回答 1

5

如果您需要ZoneOffsetor ZoneId,您可以从以下位置创建它TemporalAccessor

TemporalAccessor acc = ZonedDateTime.now();
System.out.println(ZoneOffset.from(acc));
System.out.println(ZoneId.from(acc));
于 2015-08-27T09:08:12.277 回答