In a nutshell:
java.time.ZonedDateTime
has no args constructor (actually it has noZonedDateTimeConverter
for MorphiaZonedDateTime
without converter, Morphia
saves the full ZonedDateTime
object as DBObject
which is cool because
I could read all the fields and initiate a ZonedDateTime object from
it, but I got an exception on loading: No usable constructor for java.time.ZonedDateTime
ZonedDateTime
with the converter, I got
another exception: Can't find a codec for class java.time.LocalDateTime
. I started to play with the converters, based
on this article but without any result.Any idea?
UPDATE:
Turned out that I should write a converter for each subtype started from ZonedDateTime
(e.g. LocalDateTime
, LocalDate
, LocalTime
), but turned out that I should write a converter for java.time.ZoneRegion
which is package-private.
I pushed support for the more common Java 8 datetime types to Morphia last week targeting the 1.3 release. See the issue here and the linked commits. If there's a type you need that's not listed, please file a Morphia issue and I'll try to make sure it's included in 1.3 as well.