Interface WorkingTimeCalculator

    • Method Detail

      • subtractWorkingTime

        Instant subtractWorkingTime​(Instant workStart,
                                    Duration workingTime)
                             throws InvalidArgumentException
        Subtracts workingTime from workStart. Respects the configured working time schedule and Holidays.

        The returned Instant denotes the first time in point the work time starts or in short it is inclusive.

        E.g can be used for planned date calculation.

        Parameters:
        workStart - The Instant workingTime is subtracted from.
        workingTime - The Duration to subtract from workStart. May have any resolution Duration supports, e.g. minutes or seconds.
        Returns:
        A new Instant which represents the subtraction of working time.
        Throws:
        InvalidArgumentException - If workingTime is negative.
      • addWorkingTime

        Instant addWorkingTime​(Instant workStart,
                               Duration workingTime)
                        throws InvalidArgumentException
        Adds workingTime from workStart. Respects the configured working time schedule and Holidays.

        The returned Instant denotes the first time in point the work time has ended or in short it is exclusive.

        E.g can be used for due date calculation.

        Parameters:
        workStart - The Instant workingTime is added to.
        workingTime - The Duration to add to workStart. May have any resolution Duration supports, e.g. minutes or seconds.
        Returns:
        A new Instant which represents the addition of working time.
        Throws:
        InvalidArgumentException - If workingTime is negative.
      • workingTimeBetween

        Duration workingTimeBetween​(Instant first,
                                    Instant second)
                             throws InvalidArgumentException
        Calculates the working time between first and second according to the configured working time schedule. The returned Duration is precise to nanoseconds.

        This method does not impose any ordering on first or second.

        Parameters:
        first - An Instant denoting the start or end of the considered time frame.
        second - An Instant denoting the start or end of the considered time frame.
        Returns:
        The Duration representing the working time between first and to .
        Throws:
        InvalidArgumentException - If either first or second is null.
      • isWorkingDay

        boolean isWorkingDay​(Instant instant)
        Decides whether instant is a working day.
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a working day. false otherwise.
      • isWeekend

        boolean isWeekend​(Instant instant)
        Decides whether instant is a weekend day.
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a weekend day. false otherwise.
      • isHoliday

        boolean isHoliday​(Instant instant)
        Decides whether { @code instant} is a holiday.
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a holiday. false otherwise.
      • isGermanHoliday

        boolean isGermanHoliday​(Instant instant)
        Decides whether instant is a holiday in Germany.
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a holiday in Germany. false otherwise.