Package pro.taskana.common.api
Interface WorkingTimeCalculator
- All Known Implementing Classes:
WorkingDayCalculatorImpl,WorkingTimeCalculatorImpl
public interface WorkingTimeCalculator
-
Method Summary
Modifier and TypeMethodDescriptionaddWorkingTime(Instant workStart, Duration workingTime) AddsworkingTimefromworkStart.booleanisGermanHoliday(Instant instant) Decides whetherinstantis a holiday in Germany.booleanDecides whether { @code instant} is a holiday.booleanDecides whetherinstantis a weekend day.booleanisWorkingDay(Instant instant) Decides whetherinstantis a working day.default booleanisWorkingTimeBetween(Instant first, Instant second) Decides whether there is any working time betweenfirstandsecond.subtractWorkingTime(Instant workStart, Duration workingTime) SubtractsworkingTimefromworkStart.workingTimeBetween(Instant first, Instant second) Calculates the working time betweenfirstandsecondaccording to the configured working time schedule.
-
Method Details
-
subtractWorkingTime
Instant subtractWorkingTime(Instant workStart, Duration workingTime) throws InvalidArgumentException SubtractsworkingTimefromworkStart. 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 InstantworkingTimeis subtracted from.workingTime- The Duration to subtract fromworkStart. May have any resolution Duration supports, e.g. minutes or seconds.- Returns:
- A new Instant which represents the subtraction of working time.
- Throws:
InvalidArgumentException- IfworkingTimeis negative.
-
addWorkingTime
AddsworkingTimefromworkStart. 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 InstantworkingTimeis added to.workingTime- The Duration to add toworkStart. May have any resolution Duration supports, e.g. minutes or seconds.- Returns:
- A new Instant which represents the addition of working time.
- Throws:
InvalidArgumentException- IfworkingTimeis negative.
-
workingTimeBetween
Calculates the working time betweenfirstandsecondaccording to the configured working time schedule. The returned Duration is precise to nanoseconds.This method does not impose any ordering on
firstorsecond.- 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
firstandto. - Throws:
InvalidArgumentException- If eitherfirstorsecondisnull.
-
isWorkingTimeBetween
Decides whether there is any working time betweenfirstandsecond.- Throws:
InvalidArgumentException- See Also:
-
isWorkingDay
Decides whetherinstantis a working day.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a working day.falseotherwise.
-
isWeekend
Decides whetherinstantis a weekend day.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a weekend day.falseotherwise.
-
isHoliday
Decides whether { @code instant} is a holiday.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday.falseotherwise.
-
isGermanHoliday
Decides whetherinstantis a holiday in Germany.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday in Germany.falseotherwise.
-