interface SomeDataClass {
TemporalAccessor getSomeTime();
}
//somewhere in the impl...
public TemporalAccessor getSomeTime() {
return OffsetDateTime.from(dateTimeFormatter.parse(someDateInstring));
}
有人知道如何从此
TemporalAccessor
界面获取时区数据吗? 最佳答案
如果需要ZoneOffset
或ZoneId
,则可以从TemporalAccessor
创建它:
TemporalAccessor acc = ZonedDateTime.now();
System.out.println(ZoneOffset.from(acc));
System.out.println(ZoneId.from(acc));