We're finally looking at adding support for certain Java 8 types in
Morphia. There are a number of options for how to encode each type.
We've made an initial pass at it and have an implementation but would
like to elicit some feedback before these serialization formats are
finalized. Please look over the information below and see if the
formats fit your needs and expectations. With these implementations,
the intent was to provide support for the most common needs. These new
date/time types often track values to nanosecond precision. Dates in
MongoDB do not have such precision and so certain decisions must be
made. In this initial approach, the decision was made to truncate
anything below the millisecond level. Listed below is the current
thinking of how to handle each type with some discussion where necessary
covering the decisions/tradeoffs being made and some possible options.
{ "year" : 1988, "month" : 10 } My initial implementation went that route but it was surprising to those who saw it. What was in the database didn't match the expectations set by what was in the Java code. This particular approach preserves those expectations and leave open the option of custom converters/codecs for those who need the great precision. That's the reasoning so far, at least.
--------------------------------{ name : "Justin Lee",title : "Software Engineer",twitter : "@evanchooly",location : "New York, NY" }
On Fri, Jun 3, 2016 at 3:03 AM, Ulrich Cech <devel...@gmail.com> wrote:Basically, I think we should keep the accuracy/precision of the new Time-API, so no compromisses on truncating the nanos or other changes to the original value. The toString()-representation of all units can easyly parsed back to the corresponding classes.
But I see the use-case for using the values for calculation.
So, perhaps, we can introduce some Annotation like the JPA-TemporalType, so that we can control, if the value is stored as string (and is parsed back with the exact value) or as Date for calculation (without the nanos).