Here's how to setup scheduled (periodic or timed) tasks with Spring3
in Grails using the concurrency executors introduced in Java5.
This replaces the use of a Spring2 TimerTask
which was deprecated in
Spring3 and removed from Spring4. Grails2 uses Spring3 so
the TimerTask
should still work, but this method should work
in Grails2 and Grails3. Note that in Grails3 and
possibly 2.4/2.5,
you might be able to use the much simpler Spring
@Scheduled
annotation on a service method.
It's really surprising and annoying that the default structured editor for
dates and times in Grails is so limited. It only allows one to edit (or enter)
time information down to the minute. Seconds and smaller are ignored, even
though the editor specifically returns an epoch time in milliseconds with the
getTime()
method! The default editor also only works for java.util.Date
and java.sql.Date
-- not the also common java.sql.Timestamp
.