Class WorkingTimeCalculatorImpl
- java.lang.Object
-
- pro.taskana.common.internal.workingtime.WorkingTimeCalculatorImpl
-
- All Implemented Interfaces:
WorkingTimeCalculator
public class WorkingTimeCalculatorImpl extends Object implements WorkingTimeCalculator
-
-
Constructor Summary
Constructors Constructor Description WorkingTimeCalculatorImpl(HolidaySchedule holidaySchedule, Map<DayOfWeek,Set<LocalTimeInterval>> workingTimeSchedule, ZoneId zoneId)
-
Method Summary
All Methods Instance Methods Concrete 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.InstantsubtractWorkingTime(Instant workStart, Duration workingTime)SubtractsworkingTimefromworkStart.DurationworkingTimeBetween(Instant first, Instant second)Calculates the working time betweenfirstandsecondaccording to the configured working time schedule.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface pro.taskana.common.api.WorkingTimeCalculator
isWorkingTimeBetween
-
-
-
-
Constructor Detail
-
WorkingTimeCalculatorImpl
public WorkingTimeCalculatorImpl(HolidaySchedule holidaySchedule, Map<DayOfWeek,Set<LocalTimeInterval>> workingTimeSchedule, ZoneId zoneId)
-
-
Method Detail
-
subtractWorkingTime
public Instant subtractWorkingTime(Instant workStart, Duration workingTime) throws InvalidArgumentException
Description copied from interface:WorkingTimeCalculatorSubtractsworkingTimefromworkStart. 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:
subtractWorkingTimein interfaceWorkingTimeCalculator- 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
public Instant addWorkingTime(Instant workStart, Duration workingTime) throws InvalidArgumentException
Description copied from interface:WorkingTimeCalculatorAddsworkingTimefromworkStart. 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:
addWorkingTimein interfaceWorkingTimeCalculator- 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
public Duration workingTimeBetween(Instant first, Instant second) throws InvalidArgumentException
Description copied from interface:WorkingTimeCalculatorCalculates 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.- Specified by:
workingTimeBetweenin interfaceWorkingTimeCalculator- 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.
-
isWorkingDay
public boolean isWorkingDay(Instant instant)
Description copied from interface:WorkingTimeCalculatorDecides whetherinstantis a working day.- Specified by:
isWorkingDayin interfaceWorkingTimeCalculator- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a working day.falseotherwise.
-
isWeekend
public boolean isWeekend(Instant instant)
Description copied from interface:WorkingTimeCalculatorDecides whetherinstantis a weekend day.- Specified by:
isWeekendin interfaceWorkingTimeCalculator- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a weekend day.falseotherwise.
-
isHoliday
public boolean isHoliday(Instant instant)
Description copied from interface:WorkingTimeCalculatorDecides whether { @code instant} is a holiday.- Specified by:
isHolidayin interfaceWorkingTimeCalculator- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday.falseotherwise.
-
isGermanHoliday
public boolean isGermanHoliday(Instant instant)
Description copied from interface:WorkingTimeCalculatorDecides whetherinstantis a holiday in Germany.- Specified by:
isGermanHolidayin interfaceWorkingTimeCalculator- Parameters:
instant- The Instant to check. May not benull.- Returns:
trueifinstantis a holiday in Germany.falseotherwise.
-
-