Author |
Message |
08/04/2014 18:58:41
|
edi86z
neo
Joined: 08/04/2014 18:56:57
Messages: 2
Offline
|
Hi,
I would like to create a cron trigger to fires everyday at 8am, starting from 1 September 2014 to 28 Feb 2015. I've looked through the tutorial site and I am still not too sure. Is there a way to do this?
Many thanks.
|
|
|
08/04/2014 20:45:47
|
umesh261
neo
Joined: 10/02/2013 23:33:52
Messages: 5
Offline
|
Hi,
you can create a Trigger with a cron expression and set the start date and end date on the trigger.
e.g:
Calendar startDate = Calendar.getInstance() , endDate = Calendar.getInstance() ;
startDate.set(Calendar.MONDAY,Calendar.SEPTEMBER);
startDate.set(Calendar.YEAR, 2014);
startDate.set(Calendar.DAY_OF_MONTH,1);
endDate.set(Calendar.MONDAY,Calendar.FEBRUARY);
endDate.set(Calendar.YEAR, 2015);
endDate.set(Calendar.DAY_OF_MONTH,28);
CronExpression cronExpression = new CronExpression("0 0 8 1/1 * ? *"); // Cron Expression to run daily at 8 AM
Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity("Trigger", "Group").startAt(runDate)
.withSchedule(
CronScheduleBuilder.cronSchedule(cronExpression)).startAt(startDate.getTime()).endAt(endDate.getTime())
.build();
Hope this answers your query.
|
|
|
08/04/2014 21:01:16
|
edi86z
neo
Joined: 08/04/2014 18:56:57
Messages: 2
Offline
|
Headshot! Thanks so much!
|
|
|
|