[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
CronTrigger Sep 2014 to Feb 2015  XML
Forum Index -> Quartz
Author Message
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.
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.
edi86z

neo

Joined: 08/04/2014 18:56:57
Messages: 2
Offline

Headshot! Thanks so much!
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team