Creating Business Calendar
You can create business calendars at design time using annotated Java interfaces or runtime using UI views available in the Business calendars menu.
Creating Business Calendar at Runtime
Open the Business calendars view from the main menu and click the Create button.
After that, the Business calendar editor is opened.
Specify the following parameters:
-
Name - human-readable description of the given calendar.
-
Code - unique identifier of the given calendar.
On the Holidays tab, click Create to add holidays and weekends.
The add-on supports the following types of holidays:
-
Day of week - allows specifying holiday for desired week’s days; for example, Saturday and Sunday.
-
Specific date holiday - allows setting holiday for an exact date, for example,
2022-08-03
. -
Annual holiday - repeatable yearly holidays, like the
1st of January
. -
Cron-based holiday - allows specifying holidays in the quartz CRON format. See Cron trigger tutorial for more information.
It can help specify some none trivial holidays, like the Third Friday of every month or the First Monday of July, etc.
On the Working schedule tab, you can specify working hours for each day of the week. There can be more than one working period per day, but they should not overlap.
You can define some holidays as working days on the Additional business days tab. If such a day belongs to one of the holidays, it will be considered a working day.
Creating Business Calendar at Design Time
You can create a business calendar at design time using annotated Java interfaces, 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 always a day for family") (3)
void weeklyHolidays();
@FixedDayHoliday(fixedDate = "2021-05-08") (4)
@FixedDayHoliday(fixedDate = "2021-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 = "2021-05-06",
startTime = "10:00", endTime = "16:30") (7)
@AdditionalBusinessDay(fixedDate = "2021-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 desired week’s days. |
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.