Reputation: 13
How do i customize Quartz scheduler to skip only last day of the month? I want the batch to run on all days except last day of the month. There is a cron expression to run on last day of the month but i am not able to specify the range like this 1-L-1
Any help would be greatly appreciated.
Upvotes: 0
Views: 676
Reputation: 1880
This most likely cannot be easily solved on the trigger level. However, there is one very elegant solution that allows you to exclude particular days from the trigger's firing schedule. Please check the Quatrz Calendar API.
The Calendar interface defines two methods:
public interface Calendar
{
public boolean isTimeIncluded(long timeStamp);
public long getNextIncludedTime(long timeStamp);
}
You may also want to check this Quartz tutorial.
Update: It seems that Quartz distribution contains a CronCalendar implementation that provides the functionality you are after. It allows you to use a cron expression that matches days that should be EXCLUDED from firing. Therefore, you can use a cron expression using the 'L' syntax to exclude the last day of every month.
Upvotes: 1