在我的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/