Class WorkingTimeCalculatorImpl

    • Method Detail

      • subtractWorkingTime

        public Instant subtractWorkingTime​(Instant workStart,
                                           Duration workingTime)
                                    throws InvalidArgumentException
        Description copied from interface: WorkingTimeCalculator
        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.

        Specified by:
        subtractWorkingTime in interface WorkingTimeCalculator
        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

        public Instant addWorkingTime​(Instant workStart,
                                      Duration workingTime)
                               throws InvalidArgumentException
        Description copied from interface: WorkingTimeCalculator
        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.

        Specified by:
        addWorkingTime in interface WorkingTimeCalculator
        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

        public Duration workingTimeBetween​(Instant first,
                                           Instant second)
                                    throws InvalidArgumentException
        Description copied from interface: WorkingTimeCalculator
        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.

        Specified by:
        workingTimeBetween in interface WorkingTimeCalculator
        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

        public boolean isWorkingDay​(Instant instant)
        Description copied from interface: WorkingTimeCalculator
        Decides whether instant is a working day.
        Specified by:
        isWorkingDay in interface WorkingTimeCalculator
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a working day. false otherwise.
      • isWeekend

        public boolean isWeekend​(Instant instant)
        Description copied from interface: WorkingTimeCalculator
        Decides whether instant is a weekend day.
        Specified by:
        isWeekend in interface WorkingTimeCalculator
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a weekend day. false otherwise.
      • isHoliday

        public boolean isHoliday​(Instant instant)
        Description copied from interface: WorkingTimeCalculator
        Decides whether { @code instant} is a holiday.
        Specified by:
        isHoliday in interface WorkingTimeCalculator
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a holiday. false otherwise.
      • isGermanHoliday

        public boolean isGermanHoliday​(Instant instant)
        Description copied from interface: WorkingTimeCalculator
        Decides whether instant is a holiday in Germany.
        Specified by:
        isGermanHoliday in interface WorkingTimeCalculator
        Parameters:
        instant - The Instant to check. May not be null.
        Returns:
        true if instant is a holiday in Germany. false otherwise.