[英]Handle Joda DateTime with Anorm 2.3
I'm brand new to Play! 我是Play游戏的新手! and I'm using the version 2.3.4.
我正在使用2.3.4版本。
So far I used the java.util.Date
type without problem but I finally want to use a DateTime
type. 到目前为止,我毫无疑问地使用了
java.util.Date
类型,但是我最终想要使用DateTime
类型。
So I'm trying to use the org.joda.time.DateTime
type but anorm
doesn't know how to handle this type, I get this error : could not find implicit value for parameter extractor: anorm.Column[org.joda.time.DateTime]
. 因此,我尝试使用
org.joda.time.DateTime
类型,但anorm
不知道如何处理该类型,但出现此错误: could not find implicit value for parameter extractor: anorm.Column[org.joda.time.DateTime]
。
The part of the code giving an error is : 给出错误的代码部分是:
private val ArtistParser: RowParser[Artist] = {
get[Long]("artistId") ~
get[DateTime]("creationDateTime") map {
case artistId ~ creationDateTime =>
Artist(artistId, creationDateTime)
}
}
My class is simply : 我的课很简单:
case class Artist (artistId: Long, creationDateTime: DateTime)
I have been searching a solution for a long time and I looked in particular at this post : Joda DateTime Field on Play Framework 2.0's Anorm but I think that it doesn't work with play 2.3.4 (at least I didn't manage to make it work). 我一直在寻找解决方案很长时间,尤其是看这篇文章: Play Framework 2.0的Anorm上的Joda DateTime字段,但我认为它不适用于play 2.3.4(至少我没有这么做)设法使其工作)。
So my question is how do you handle DateTime
with play scala 2.3? 所以我的问题是,如何使用play scala 2.3处理
DateTime
? Is there an easiest way to proceed? 有最简单的方法吗? And if not what should I do in order to
anorm
to handle correctly the DateTime
type? 而如果不是我应该怎样才能做到
anorm
正确处理DateTime
类型?
Anorm typeclasses for Joda DateTime
and Instant
are present in play master. 播放主机中存在Joda
DateTime
和Instant
Anorm类型类。 You may want to give it a try. 您可能需要尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.