0

I am using scalike as a simple sql connector.

To retrieve sql.timestamp to LocalDateTime we use wrappedResultSet.localDateTime(1).

Unfortunately, it does add an offset (+1 in my case).

By digging the scalike code, I have seen this is a "feature":

implicit def javaTimeLocalDateTime(implicit z: OverwrittenZoneId): TypeBinder[LocalDateTime] =
    Binders.sqlTimestamp.map(Binders.convertJavaTimeLocalDateTime(z.value))

How could I convert sql.timestamp to LocalDateTime without adding any offset ?

I already tried by overloading the z value without success

implicit val z: OverwrittenZoneId = OverwrittenZoneId(ZoneId.of("UTC"))
BlueSheepToken
  • 5,751
  • 3
  • 17
  • 42
  • As of JDBC 4.2, we can directly exchange *java.time* objects with the database. So there is no need to use legacy classes like `java.sql.Timestamp`. Has your *scalike* tool not yet been updated to support *java.time*? – Basil Bourque Feb 17 '20 at 16:56
  • @BasilBourque, I ll have a look at it, thanks – BlueSheepToken Feb 17 '20 at 17:13
  • We use scalike with `java.time.OffsetDateTime` directly, so maybe you could use that and specify the offset you want? – felixbr Feb 18 '20 at 20:15

0 Answers0