如何绑定LocalDateTime
或LocalDate
类型的域类字段以在Grails 3中形成输入?
答案 0 :(得分:0)
将其添加到build.gradle
文件中的依赖项:
compile "org.hibernate:hibernate-java8:5.1.3.Final"
应该允许您拥有这样的域名:
class Test {
LocalDateTime start
Duration duration
}
创建对象:
new Test(start: LocalDateTime.of(2017,1,1,8,0,0), duration: Duration.ofHours(5)).save()
在数据库中看起来像这样:
+----+---------+----------------+---------------------+
| id | version | duration | start |
+----+---------+----------------+---------------------+
| 1 | 0 | 18000000000000 | 2017-01-01 08:00:00 |
+----+---------+----------------+---------------------+
答案 1 :(得分:0)