java - Compatibility between Instant and ZonedDateTime -


it understanding zoneddatetime enhanced version of instant. has data instant has (precise value along utc timeline), plus time zone information. naïve assumption zoneddatetime is-an instant , method taking instant happily take zoneddatetime instead. furthermore, expected isbefore(), isafter() etc. work seamlessly between instants , zoneddatetimes.

looking @ api documentation instant , zoneddatetime, none of case. can compare instants instants , zoneddatetimes zoneddatetimes, 2 classes seem incompatible. what's more, third-party code threeten-extra's interval seem work exclusively instants.

is there reason why instant , zoneddatetime not meant mixed?

because translation not injective. take sunday, october 30th 2016 2:15 in germany/munich example: instant date/time represent? not independently answerable without assumptions because don't know if time should translated instant before or after offset daylight saving time (dst) should applied. or sunday, march 27th 2016 2:15 in germany/munich: date/time combination should not exist, clock should set 3 when reaching 2 am.

without dst 3 possible cases translating localdatetime instant (exact match, summertime-gap, wintertime-overlap) reduced 1 , conversion injective, afaik.

edit: "hands on" problem, when displaying date/time in our jsf based application, always pass offset calculated accordingly current state of dst formatter.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -