BusinessCelenderImpl can't calculate Business Date correctly

Solution In Progress - Updated -

Issue

When I test BusinessCalenderImpl like the following, it does not work as expected.

    @Test
    public void testCalculateMinutesPassingOverHolidays() {
        Properties config = new Properties();
        config.setProperty(BusinessCalendarImpl.DAYS_PER_WEEK, "5");
        config.setProperty(BusinessCalendarImpl.HOURS_PER_DAY, "8");
        config.setProperty(BusinessCalendarImpl.START_HOUR, "9");
        config.setProperty(BusinessCalendarImpl.END_HOUR, "18");
        config.setProperty(BusinessCalendarImpl.WEEKEND_DAYS, "1,7"); // sun,sat
        config.setProperty(BusinessCalendarImpl.HOLIDAYS, "2018-04-30,2018-05-03,2018-05-04,2018-05-05");
        config.setProperty(BusinessCalendarImpl.HOLIDAY_DATE_FORMAT, "yyyy-MM-dd");
        String expectedDate = "2018-05-08 13:00"; // 5/1 -> 5/2 -> 5/7 -> 5/8

        SessionPseudoClock clock = new StaticPseudoClock(parseToDateWithTime("2018-05-01 13:00").getTime());
        BusinessCalendarImpl businessCal = new BusinessCalendarImpl(config, clock);


        Date result = businessCal.calculateBusinessTimeAsDate("P3D");

        assertEquals(expectedDate, formatDate("yyyy-MM-dd HH:mm", result));
    }

In this example, it calculates business time at 2018-05-01 13:00 with 3 days (P3D) duration.
Expected date and time is 2018-05-08 13:00 as from 5/3 to 5/5 are holiday and 5/6 is Sunday.
But it's returns '2018-05-07 13:00'. Is this a bug?

Environment

  • Red Hat Process Automation Manager
    • 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.