나는 대부분의 사람들이 JodaTime을 사용하고 있다고 믿기 때문에 왜 실종되었는지 설명 할 수 있습니다. Anorm의 일부가 아닌 경우 자체 변환기를 작성할 수 있습니다.
이 안된하지만
import java.time.Instant
import java.time.format.DateTimeFormatter
import java.util.TimeZone
import anorm._
object InstantAnormExtension {
val dateFormatGeneration = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss-Z")
implicit def rowToDateTime: Column[Instant] = Column.nonNull { (value, meta) =>
val MetaDataItem(qualified, nullable, clazz) = meta
value match {
case ts: java.sql.Timestamp => Right(ts.toInstant)
case d: java.sql.Date => Right(d.toInstant)
case str: java.lang.String => Right(Instant.from(dateFormatGeneration.parse(str)))
case _ => Left(TypeDoesNotMatch("Cannot convert " + value + ":" + value.asInstanceOf[AnyRef].getClass))
}
}
implicit val dateTimeToStatement = new ToStatement[Instant] {
def set(s: java.sql.PreparedStatement, index: Int, aValue: Instant): Unit = {
if(aValue == null) {
s.setTimestamp(index, null)
} else {
s.setTimestamp(index, java.sql.Timestamp.from(aValue))
}
}
}
}
이 https://github.com/playframework/anorm/pull/10 – cchantep