NOTE:
The clj-time
library is based on the old Joda Time library. Both of these have been deprecated in favor of java.time
(available since JDK 8). It is best to use Java interop with java.time instead of the older clj-time
library.
The package java.time
is basically Joda Time 2.0, but rewritten to be cleaner and to correct some corner cases. Both were created by the same person.
Answer:
In Java, a LocalDate
doesn't have a timezone. That is the whole point.
It is used for things like a birthday, such as 1999-12-31, where we don't consider your birthday to have a timezone.
For the same reason, the LocalDate
doesn't have any time associated with it, just as your birthday is considered to be the entire day.
See the java.time
docs for more information: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/package-summary.html
From the JavaDocs:
Dates and Times
Instant is essentially a numeric timestamp. The
current Instant can be retrieved from a Clock. This is useful for
logging and persistence of a point in time and has in the past been
associated with storing the result from System.currentTimeMillis().
LocalDate stores a date without a time. This stores a date like
'2010-12-03' and could be used to store a birthday.
LocalTime stores a time without a date. This stores a time like
'11:30' and could be used to store an opening or closing time.
LocalDateTime stores a date and time. This stores a date-time like
'2010-12-03T11:30'.
ZonedDateTime stores a date and time with a time-zone. This is useful
if you want to perform accurate calculations of dates and times taking
into account the ZoneId, such as 'Europe/Paris'. Where possible, it is
recommended to use a simpler class without a time-zone. The widespread
use of time-zones tends to add considerable complexity to an
application.
Helper functions:
I have added some convenience functions to aid the usage of java.time
that you may find useful.