How to use DateTime in Slick2.0?

后端 未结 2 1582
逝去的感伤
逝去的感伤 2021-01-17 21:20

I want to use DateTime in Slick 2.0 model. I use jodatime:

I added the dependencies in Build.scala:

   \"joda-time\" % \"jo         


        
相关标签:
2条回答
  • 2021-01-17 22:10

    The other answer mentioned the library, but if you want to just create your own mapper and have it in the class, this is one such example:

    implicit def dateTime =
        MappedColumnType.base[DateTime, Timestamp](
          dt => new Timestamp(dt.getMillis),
          ts => new DateTime(ts.getTime)
        )
    

    Source: Paul Coghlan (@paulcoghlan)'s comment on Gist here https://gist.github.com/dragisak/4756344#comment-1211671

    0 讨论(0)
  • 2021-01-17 22:17

    Take a look at https://github.com/tototoshi/slick-joda-mapper or you must create your own type mapper

    0 讨论(0)
提交回复
热议问题