Add method for summing EffortDurations
FEA: ItEr60S19TimeUnitDataType
This commit is contained in:
parent
bef951f827
commit
8334cc2b2e
2 changed files with 19 additions and 0 deletions
|
|
@ -133,6 +133,18 @@ public class EffortDuration implements Comparable<EffortDuration> {
|
|||
return EffortDuration.seconds(this.seconds * integer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluses two {@link EffortDuration}. <br />
|
||||
* <b>Warning:<b /> This method can cause an integer overflow and the result
|
||||
* would be incorrect.
|
||||
* @param other
|
||||
* @return a duration that is the sum of <code>this</code>
|
||||
* {@link EffortDuration} and the other duration
|
||||
*/
|
||||
public EffortDuration plus(EffortDuration other) {
|
||||
return new EffortDuration(seconds + other.seconds);
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
return seconds == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,4 +134,11 @@ public class EffortDurationTest {
|
|||
assertThat(min, equalTo(seconds(10)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void effortDurationsCanBePlused() {
|
||||
EffortDuration a = EffortDuration.hours(1).and(30, Granularity.MINUTES);
|
||||
EffortDuration b = EffortDuration.minutes(30);
|
||||
assertThat(a.plus(b), equalTo(EffortDuration.hours(2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue