I am thinking of using the new java 8 Date Time API. I googled a bit and found jodaTime as good choice for java but still kind of interested to see how this new API works.
I am storing all time in UTC values in my datastore and will be converting them to Local Time Zone specific value based on user's timezone. I can find many articles showing how to use new Java Date Time API. However I am not sure if the API will take care of DST changes ? Or do we have any better way of handling Date ?
I am just learning the new Date API , so thought of hearing your thoughts on handling the DateTime and displaying it on the basis of Users TimeZone.
It depends on which class you use:
Instant
is an instantaneous point on the global time-line (UTC), and is unrelated to time-zone.LocalDate
and LocalDateTime
have no concept of time-zone, but calling now()
will of course give you your correct time.OffsetDateTime
has a time-zone, but doesn't support Daylight Savings Time.ZonedDateTime
has full time-zone support.Converting between them usually requires a time-zone, so to answer your question:
Yes, Java 8 Date/Time can take care of DST, if you use it right.