Reputation: 1360
I'm working on a small event calendar in groovy and grails and i want to display only todays events.
def getEventsToday(List events) {
List eventsToday;
Date todayEvening = dateDefault(null, null, null, 23, 59, 59);
Date todayMorning = dateDefault(null, null, null, 0, 0, 0);
eventsToday = events.ByStartTimeBetween(todayEvening, todayMorning);
return eventsToday;
}
I get the following exception:
groovy.lang.MissingMethodException: No signature of method: EventController.dateDefault() is applicable for argument types: (null, null, null, java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [null, null, null, 23, 59, 59]
I think the dateDefault() Method is missing but i don't know in wich class i could find this method. Maybe someone knows a possible solution for my use-case / problem?
/edit/ This doesn't work too because today is null: Code http://img7.imagebanana.com/img/mracvfus/Bildschirmfoto20110605um11.32.57.png
Thanks for help! whitenexx
Upvotes: 0
Views: 208
Reputation: 187537
Assuming the List events
argument contains a collection of objects that have a Date startTime
property, the following should work:
def getEventsToday(List events) {
Date today = new Date().clearTime()
events.findAll {event ->
event.clearTime() == today
}
}
Upvotes: 1