open-feature / java-sdk

Java implementation of the OpenFeature SDK
https://openfeature.dev
Apache License 2.0
78 stars 36 forks source link

Instant instead of ZonedDateTime #59

Closed agentgonzo closed 1 year ago

agentgonzo commented 1 year ago

Instant is a more ideomatic way of representing times in java (akin to unix time). It's a timezone-less entity (ie, UTC).

There are a bunch of helper functions to do any conversions you may want, as well as to/from ISO-8601 zulu-time strings.

ZonedDateTime contains timezone information, which (whilst useful) can introduce confusion when dealing with distributed systems. Ideally, all backend/server code (ie, Java) would use Instant (ie, fancy-formatted unix time) for all datetime representations, then leave it up to the frontend to worry about formatting with specific timezones.

I think it's worth changing https://github.com/open-feature/java-sdk/blob/main/src/main/java/dev/openfeature/javasdk/Value.java#L49-L51 to be using Instant instead of ZonedDateTime

toddbaert commented 1 year ago

I'm in agreement with this suggestion, though we also had a brief discussion on whether or not we wanted to include timestamps as "first class" data in the context or structure return values at all.

I think I'd like to keep timestamps as a first class type in the context, but I'm interested if others think it's worth the burden.