Class 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)
    Format
    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
    each holiday period should be separated from next one with comma: 2012-05-01:2012-05-15,2012-12-24:2012-12-27
    Holiday date format must be given in pattern that is supported by java.text.SimpleDateFormat.
    Weekend days should be given as integer that corresponds to java.util.Calendar constants.
    • 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()
      • adoptISOFormat

        protected String adoptISOFormat​(String timeExpression)
      • 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 interface BusinessCalendar
        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 interface BusinessCalendar
        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)
      • getPropertyAsInt

        protected int getPropertyAsInt​(String propertyName,
                                       String defaultValue)
      • 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)