Creating Business Calendar
You can create business calendars both at runtime using a special visual editor, or at design time with annotated Java interfaces.
Creating Business Calendar at Runtime
After the add-on is installed, use the main menu to open the Business calendars list view.
When on this page, click the Create button to open the Business calendar editor.
Specify the following parameters:
-
Name – human-readable description of the given calendar.
-
Code – unique identifier of the given calendar.
The next step is to define working days and hours while excluding non-working time, such as holidays, vacations, or any other time off work. For this, use the editor’s tabs described below.
Holidays
On the Holidays tab, click Create to add holidays and weekends.
The add-on supports the following types of holidays:
-
Day of week – allows to set holidays on certain days of week. For example, for many people, the standard weekend is Saturday and Sunday:
-
Specific date holiday – allows to set a holiday on an exact date. For example, some holidays fall on a different day every year to allow people a long weekend:
-
Annual holiday – allows to schedule recurring holidays that are celebrated on the same day every year, such as New Year’s Day.
-
Cron-based holiday – allows specifying holidays in the quartz CRON format. See Cron trigger tutorial for more information.
It can help adding some nontrivial holidays, like the Third Friday of every month or the First Monday of July, etc.
Creating Business Calendar at Design Time
Use annotated Java interface to create a business calendar at design time. For example:
@BusinessCalendar(name = "Sample Business Calendar",
code = "sample-business-calendar") (1)
public interface SampleBusinessCalendar {
@CronHoliday(expression = "* * * 1-2 MAY ?") (2)
@CronHoliday(expression = "* * * ? * 6#3")
void cronHoliday();
@WeeklyHoliday(DayOfWeek.SATURDAY)
@WeeklyHoliday(value = DayOfWeek.SUNDAY,
description = "Sunday is a day for family") (3)
void weeklyHolidays();
@FixedDayHoliday(fixedDate = "2024-05-08") (4)
@FixedDayHoliday(fixedDate = "2024-05-09")
void fixedHoliday();
@FixedYearlyHoliday(month = Month.NOVEMBER, dayOfMonth = 4) (5)
@FixedYearlyHoliday(month = Month.JUNE, dayOfMonth = 12)
void fixedYearlyHoliday();
@ScheduledBusinessDay(dayOfWeek = DayOfWeek.MONDAY,
startTime = "08:00", endTime = "17:00") (6)
@ScheduledBusinessDay(dayOfWeek = DayOfWeek.WEDNESDAY,
startTime = "09:00", endTime = "17:00")
@ScheduledBusinessDay(dayOfWeek = DayOfWeek.FRIDAY,
startTime = "10:00", endTime = "15:00")
void scheduledBD();
@AdditionalBusinessDay(fixedDate = "2024-05-06",
startTime = "10:00", endTime = "16:30") (7)
@AdditionalBusinessDay(fixedDate = "2024-05-07",
startTime = "10:00", endTime = "16:30")
void additionalBD();
}
1 | Annotated business calendar is an interface annotated with the @BusinessCalendar annotation. You should specify the following parameters for the @BusinessCalendar annotation:
|
2 | Specify holiday in the quartz CRON format. |
3 | Specify holiday for days of the week. |
4 | Specify holiday for a specific date. |
5 | Specify holiday for an annually recurring date. |
6 | Specify scheduled business days. |
7 | Specify additional business days. |
A business calendar created at the design time is displayed in the list of all business calendars and is available only for viewing.