Package pro.taskana.common.api
Interface WorkingTimeCalculator
-
- All Known Implementing Classes:
WorkingTimeCalculatorImpl
public interface WorkingTimeCalculator
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description InstantaddWorkingTime(Instant workStart, Duration workingTime)AddsworkingTimefromworkStart.booleanisGermanHoliday(Instant instant)Decides whetherinstantis a holiday in Germany.booleanisHoliday(Instant instant)Decides whether { @code instant} is a holiday.booleanisWeekend(Instant instant)Decides 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.InstantsubtractWorkingTime(Instant workStart, Duration workingTime)SubtractsworkingTimefromworkStart.DurationworkingTimeBetween(Instant first, Instant second)Calculates the working time betweenfirstandsecondaccording to the configured working time schedule.
-
-
-
Method Detail
-
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
Instant addWorkingTime(Instant workStart, Duration workingTime) throws InvalidArgumentException
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
Duration workingTimeBetween(Instant first, Instant second) throws InvalidArgumentException
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
default boolean isWorkingTimeBetween(Instant first, Instant second) throws InvalidArgumentException
Decides whether there is any working time betweenfirstandsecond.- Throws:
InvalidArgumentException- See Also:
workingTimeBetween(Instant, Instant)
-
isWorkingDay
boolean isWorkingDay(Instant instant)
Decides whetherinstantis a working day.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a working day.falseotherwise.
-
isWeekend
boolean isWeekend(Instant instant)
Decides whetherinstantis a weekend day.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a weekend day.falseotherwise.
-
isHoliday
boolean isHoliday(Instant instant)
Decides whether { @code instant} is a holiday.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday.falseotherwise.
-
isGermanHoliday
boolean isGermanHoliday(Instant instant)
Decides whetherinstantis a holiday in Germany.- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday in Germany.falseotherwise.
-
-