Example usage for org.apache.commons.lang3.math Fraction intValue

List of usage examples for org.apache.commons.lang3.math Fraction intValue

Introduction

In this page you can find the example usage for org.apache.commons.lang3.math Fraction intValue.

Prototype

@Override
public int intValue() 

Source Link

Document

Gets the fraction as an int.

Usage

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();
}