Reputation: 1029
interface SomeDataClass {
TemporalAccessor getSomeTime();
}
//somewhere in the impl...
public TemporalAccessor getSomeTime() {
return OffsetDateTime.from(dateTimeFormatter.parse(someDateInstring));
}
Does anyone know how to get timezone data from this TemporalAccessor
interface?
Upvotes: 1
Views: 1602
Reputation: 100279
If you need the ZoneOffset
or ZoneId
, you can create it from the TemporalAccessor
:
TemporalAccessor acc = ZonedDateTime.now();
System.out.println(ZoneOffset.from(acc));
System.out.println(ZoneId.from(acc));
Upvotes: 5