oracle - Grails Gorm find从数据库中检索不同的日期值

标签 oracle grails groovy

在我的Oracle数据库中,有一个Agreement表,该表的列effectivityDate的数据类型为DATE。当我尝试查询某行时

select * from agreement where id = 'GB'

它返回带有该值的行:
id: GB
name: MUITF - Double bypass
...
effectivityDate: 7/2/2015

我为此创建了一个Grails Domain类:
class Agreement implements Serializable {
    String id
    Date effectivityDate

    static mapping = {
        table "agreement"
        varsion: false
        id column: "id"
        name column: "name"
        ...
        effectivityDate column: "effectivityDate"
    }
}

但是当我尝试使用以下命令在groovy上查询它时:
Agreement a = Agreement.findById("GB")
println a

它返回这个对象:
[id:GB, name:MUITF - Double bypass, ..., effectivityDate: 2015-07-01T16:00:00Z]
                                                          ^^^^^^^^^^^^^^^^^^^^

我的问题是,为什么直接从数据库中获取的日期与gorm检索的日期不同?这与时区有关吗?

最佳答案

刚在您的个人资料中看到您来自菲律宾(PHT,GMT + 8)。

由于是2015-07-01T16:00:00Z === 2015-07-02T00:00:00+08:00,所以最可能的原因是查询数据库时使用PHT时区显示日期,而使用Groovy / grails查询/显示时则使用GMT / Zulu时区。

关于oracle - Grails Gorm find从数据库中检索不同的日期值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31181716/

相关文章:

tomcat - 检测正在运行的 Grails 应用程序的端口

android - 从自定义任务中运行gradle任务

c# - LINQ 使用 "like"而不是 "(( NVL(INSTR(x, y), 0) ) = 1)"

sql-server - 从 SQL Server 到 Oracle 的数据类型转换

grails - 创建简单的插入表单时,Grails字段插件如何工作?

xml - 从Grails插件中的doWithWebDescriptor闭包更改web.xml值

java - 在 Java 属性中使用 Groovy 进行变量扩展

sql - 无法删除表 SQL 错误 : ORA-00600

SQL 汇总还是联合?

hibernate - 为什么Grails不返回我要找的东西?