Package org.jbpm.process.core.timer
Class BusinessCalendarImpl
- java.lang.Object
-
- org.jbpm.process.core.timer.BusinessCalendarImpl
-
- All Implemented Interfaces:
BusinessCalendar
public class BusinessCalendarImpl extends Object implements BusinessCalendar
Default implementation of BusinessCalendar interface that is configured with properties. Following are supported properties:- business.days.per.week - specifies number of working days per week (default 5)
- business.hours.per.day - specifies number of working hours per day (default 8)
- business.start.hour - specifies starting hour of work day (default 9AM)
- business.end.hour - specifies ending hour of work day (default 5PM)
- business.holidays - specifies holidays (see format section for details on how to configure it)
- business.holiday.date.format - specifies holiday date format used (default yyyy-MM-dd)
- business.weekend.days - specifies days of the weekend (default Saturday and Sunday)
- business.cal.timezone - specifies time zone to be used (if not given uses default of the system it runs on)
Holidays can be given in two formats:- as date range separated with colon - for instance 2012-05-01:2012-05-15
- single day holiday - for instance 2012-05-01
Holiday date format must be given in pattern that is supported byjava.text.SimpleDateFormat
.
Weekend days should be given as integer that corresponds tojava.util.Calendar
constants.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DAYS_PER_WEEK
static String
END_HOUR
static String
HOLIDAY_DATE_FORMAT
static String
HOLIDAYS
static String
HOURS_PER_DAY
static String
START_HOUR
static String
TIMEZONE
static String
WEEKEND_DAYS
-
Constructor Summary
Constructors Constructor Description BusinessCalendarImpl()
BusinessCalendarImpl(String propertiesLocation)
BusinessCalendarImpl(Properties configuration)
BusinessCalendarImpl(Properties configuration, org.kie.api.time.SessionClock clock)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
adoptISOFormat(String timeExpression)
Date
calculateBusinessTimeAsDate(String timeExpression)
Calculates given time expression into target date based on calendar configuration.long
calculateBusinessTimeAsDuration(String timeExpression)
Calculates given time expression into duration in milliseconds based on calendar configuration.protected long
getCurrentTime()
protected int
getPropertyAsInt(String propertyName, String defaultValue)
protected void
handleHoliday(Calendar c, boolean resetTime)
protected void
handleWeekend(Calendar c, boolean resetTime)
protected void
init()
protected boolean
isHoliday(Calendar c)
protected boolean
isWorkingDay(int day)
protected boolean
isWorkingDay(Calendar c)
protected List<org.jbpm.process.core.timer.BusinessCalendarImpl.TimePeriod>
parseHolidays()
protected void
parseWeekendDays()
-
-
-
Field Detail
-
DAYS_PER_WEEK
public static final String DAYS_PER_WEEK
- See Also:
- Constant Field Values
-
HOURS_PER_DAY
public static final String HOURS_PER_DAY
- See Also:
- Constant Field Values
-
START_HOUR
public static final String START_HOUR
- See Also:
- Constant Field Values
-
END_HOUR
public static final String END_HOUR
- See Also:
- Constant Field Values
-
HOLIDAYS
public static final String HOLIDAYS
- See Also:
- Constant Field Values
-
HOLIDAY_DATE_FORMAT
public static final String HOLIDAY_DATE_FORMAT
- See Also:
- Constant Field Values
-
WEEKEND_DAYS
public static final String WEEKEND_DAYS
- See Also:
- Constant Field Values
-
TIMEZONE
public static final String TIMEZONE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BusinessCalendarImpl
public BusinessCalendarImpl()
-
BusinessCalendarImpl
public BusinessCalendarImpl(String propertiesLocation)
-
BusinessCalendarImpl
public BusinessCalendarImpl(Properties configuration)
-
BusinessCalendarImpl
public BusinessCalendarImpl(Properties configuration, org.kie.api.time.SessionClock clock)
-
-
Method Detail
-
init
protected void init()
-
calculateBusinessTimeAsDuration
public long calculateBusinessTimeAsDuration(String timeExpression)
Description copied from interface:BusinessCalendar
Calculates given time expression into duration in milliseconds based on calendar configuration.- Specified by:
calculateBusinessTimeAsDuration
in interfaceBusinessCalendar
- Parameters:
timeExpression
- time expression that is supported by business calendar implementation.- Returns:
- duration expressed in milliseconds
-
calculateBusinessTimeAsDate
public Date calculateBusinessTimeAsDate(String timeExpression)
Description copied from interface:BusinessCalendar
Calculates given time expression into target date based on calendar configuration.- Specified by:
calculateBusinessTimeAsDate
in interfaceBusinessCalendar
- Parameters:
timeExpression
- time expression that is supported by business calendar implementation.- Returns:
- date when given time expression will match in the future
-
handleHoliday
protected void handleHoliday(Calendar c, boolean resetTime)
-
parseHolidays
protected List<org.jbpm.process.core.timer.BusinessCalendarImpl.TimePeriod> parseHolidays()
-
parseWeekendDays
protected void parseWeekendDays()
-
getCurrentTime
protected long getCurrentTime()
-
isHoliday
protected boolean isHoliday(Calendar c)
-
isWorkingDay
protected boolean isWorkingDay(Calendar c)
-
isWorkingDay
protected boolean isWorkingDay(int day)
-
handleWeekend
protected void handleWeekend(Calendar c, boolean resetTime)
-
-