The following summary is taken from here.
|Class or Enum||Year||Month||Day||Hrs||Mins||Secs*||Zone Offset||Zone ID|
* Seconds are captured to nanosecond precision.
** This class does not store this information, but has methods to provide time in these units.
*** When a
Period is added to a
ZonedDateTime, daylight saving time or other local time differences are observed.
Instant represents a specific point on the timeline, in UTC. Useful for business logic, data storage, and data exchange.
LocalDateTime represents a date and time, but without any timezone or offset information.
ZoneOffset represents an offset-from-UTC - a number of hours, minutes, and seconds ahead of or behind UTC.
ZoneId is used to represent a time zone. It handles rules relating to daylight savings, and other periodic or one-off corrections and adjustments - both in the past and into the future (as far as can be reasonably forecast).
Zones therefore carry much more useful data than zone offsets.
An example where
LocalDateTime can be an advantage: Future dates/appointments. For these, consider storing a
LocalDateTime with a separate
ZoneId. This data can then be converted to a
ZonedDateTime when needed.
See here for more info.