First is if I want to map datetime with timezone to Slick, which class should I use OffsetDateTime
or ZonedDateTime
? As for Joda, we can only use DateTime
.
How I can write some implicit to convert between java8 ZonedDateTime
and Sql Timestamp
for Slick table mapping?
It seems quite straightforward to use joda DateTime
to include timezone information. However once switch to Java8, not quite sure whether I should use ZonedDateTime
or OffsetDateTime
, as http://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html suggests to use OffsetDateTime.
For my current code, I just use Java8 LocalDateTime
and I write following implicit to map between slick.
implicit val JavaLocalDateTimeMapper = MappedColumnType.base[LocalDateTime, Timestamp](
l => Timestamp.valueOf(l),
t => t.toLocalDateTime
)
Not quite sure I can write similar using either ZonedDateTime
or OffsetDateTime
?