List of usage examples for org.apache.commons.lang3.math Fraction intValue
@Override public int intValue()
Gets the fraction as an int
.
From source file:org.libreplan.web.resourceload.LoadPeriodGenerator.java
private int calculateLoadPercentage(EffortDuration totalEffort, EffortDuration effortAssigned) { if (totalEffort.isZero()) { return effortAssigned.isZero() ? 0 : Integer.MAX_VALUE; }// w w w .j av a 2s . c om if (effortAssigned.isZero()) { LOG.warn("total effort is " + totalEffort + " but effortAssigned is zero"); getEffortAssigned(); return 0; } Fraction fraction = effortAssigned.divivedBy(totalEffort); Fraction percentage = fraction.multiplyBy(Fraction.getFraction(100, 1)); return percentage.intValue(); }