Grails 3 java时间表绑定

时间:2017-06-01 19:02:20

标签: grails

如何绑定LocalDateTimeLocalDate类型的域类字段以在Grails 3中形成输入?

2 个答案:

答案 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)

grails-java8插件可以正常工作

https://github.com/grails-plugins/grails-java8

注意你还需要hibernate-java8依赖