0
我正在构建一个标准,以获取某个域类的所有昨天创建的记录。喜欢的东西Grails昨天的标准
def c = A.createCriteria().list {
eq(<some operation on dateCreated>, <some operation on 'now'>)
}
在此先感谢
我正在构建一个标准,以获取某个域类的所有昨天创建的记录。喜欢的东西Grails昨天的标准
def c = A.createCriteria().list {
eq(<some operation on dateCreated>, <some operation on 'now'>)
}
在此先感谢
如何
Date today = new Date().clearTime()
Date yesterday = today - 1
def c = A.createCriteria().list {
ge(yesterday)
lt(today)
}
见例如标准在这里:http://www.grails.org/doc/1.3.7/ref/Domain%20Classes/withCriteria.html
def now = new Date()
between('dateCreated', now-1, now)
将让你的现在在24小时内创造了一切。只需使用标准的Java日期操作即可将您的现在设置为午夜。
应改为: '今天日期=新的日期() today.clearTime()' 很好的回答,虽然@ – ekawas 2012-12-08 00:05:01
@ekawas这取决于你的常规版本,在新版本(我认为从内存1.8)clearTime()返回Date。请参阅http://groovy.codehaus.org/groovy-jdk/java/util/Date.html#clearTime%28%29 – Fletch 2012-12-11 09:11:23
糟糕,您的权利。你能猜到我使用的是什么版本;-) – ekawas 2012-12-11 14:34:56