光滑的列映射器java.sql.Time到Joda LocalTime

时间:2015-06-16 20:10:25

标签: scala jodatime slick

希望将java.sql.time映射到一些joda时间类。遇到映射器的一些问题,它会抛出一条错误消息。有没有人进行过这种转换?

trait DateMapper {
  implicit val DateMapper =
    MappedColumnType .base[java.sql.Time, org.joda.time.LocalTime] (
      d => new LocalTime(d.getTime))

}

错误

Unspecified value parameters: tcomap:(LocalTime) => Time

1 个答案:

答案 0 :(得分:3)

问题是您错过了LocalTime => Time转化的ResultSet -> Scala Collection转换:

MappedColumnType.base[java.sql.Time, org.joda.time.LocalTime] (
  time => new LocalTime(time.getTime),
  localTime => new Time(localTime.toDateTimeToday().getMillis()))