I am in the process of upgrading grails 2.2 to grails 4.0.10.
In grails 2.2 which used java 7 this used to work
def eanalytics = EventAnalytics.createCriteria().get(){
eq('event', raceGroup)
lt('dateCreated', timeService.now())
gt('dateCreated', timeService.now() - 1)
}
now for grails 4 and java 8 i am getting this exception
Caused by: groovy.lang.MissingMethodException: No signature of method: java.util.Date.minus() is applicable for argument types: (Integer) values: [1]
Possible solutions: find(), find(groovy.lang.Closure), is(java.lang.Object), any(), print(java.io.PrintWriter), use([Ljava.lang.Objec
Seems like i cannot get a new date by just subtracting the number of days to date in java 8. What is the equivalent code for doing this ? Thanks for the help.
timeservice.now is
def now(){
def now = new Date()
return now
}
The Date extension methods were moved into org.codehaus.groovy:groovy-dateutil
. If you add a dependency on that library, the minus
method should start working.