[hibernate-dev] HSEARCH Java 8 Date Time
Gunnar Morling
gunnar at hibernate.org
Wed Aug 5 06:10:27 EDT 2015
Hi,
What's the motivation for using a different representation in that case?
For the sake of consistency, I'd use milli seconds since 1970-01-01 across
the board. Otherwise it'll be more difficult to compare fields created from
properties of different date types.
--Gunnar
2015-08-04 19:49 GMT+02:00 Davide D'Alto <davide at hibernate.org>:
> Hi,
> I started to work on the creation of the bridges for the classes in the
> java.time package.
>
> I was wondering if we want to convert the values to long using the existing
> approach we have now for java.util.Date.
>
> In Hibernate Search a java.util.Date is converted into a long that
> represents the number of milliseconds since January 1, 1970, 00:00:00 GMT
> using getTime().
>
> The same value can be obtain from a java.time.LocaDate via:
>
> long epochMilli = date.atStartOfDay( ZoneOffset.UTC
> ).toInstant().toEpochMilli();
>
> LocalDate has a method that returns the same value expressed in number of
> days:
>
> long epochDay = date.toEpochDay();
>
>
> I would use the second approach
>
> Davide
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
More information about the hibernate-dev
mailing list