Add a method to return division result as BigDecimal.

FEA: ItEr75S27PerProjectDashboard
This commit is contained in:
Nacho Barrientos 2011-11-02 17:18:30 +01:00 committed by Manuel Rego Casasnovas
parent 2b3fb8c573
commit b1f2c89589

View file

@ -266,6 +266,24 @@ public class EffortDuration implements Comparable<EffortDuration> {
return Fraction.getFraction(this.seconds, effortAssigned.seconds);
}
/**
* <p>
* Divides this duration by other (using total seconds) returning the
* quotient as BigDecimal.
* </p>
* @param other
* @return
*/
public BigDecimal dividedByAndResultAsBigDecimal(EffortDuration other) {
if (other.isZero()) {
return BigDecimal.ZERO;
}
else {
return new BigDecimal(this.getSeconds()).divide(
new BigDecimal(other.getSeconds()), 8, BigDecimal.ROUND_HALF_EVEN);
}
}
/**
* Calculates the remainder resulting of doing the integer division of both
* durations