Example usage for java.math BigDecimal ROUND_HALF_DOWN

List of usage examples for java.math BigDecimal ROUND_HALF_DOWN

Introduction

In this page you can find the example usage for java.math BigDecimal ROUND_HALF_DOWN.

Prototype

int ROUND_HALF_DOWN

To view the source code for java.math BigDecimal ROUND_HALF_DOWN.

Click Source Link

Document

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.

Usage

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getObligatedTotalIndirect() {
    BigDecimal obligatedTotalIndirect = null;
    if (awardAmountInfo.getObligatedTotalIndirect() != null) {
        obligatedTotalIndirect = new BigDecimal(awardAmountInfo.getObligatedTotalIndirect().doubleValue());
        obligatedTotalIndirect = obligatedTotalIndirect.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from  w ww .j a  va2 s  .com*/
    return obligatedTotalIndirect;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getObligatedTotalDirect() {
    BigDecimal obligatedTotalDirect = null;
    if (awardAmountInfo.getObligatedTotalDirect() != null) {
        obligatedTotalDirect = new BigDecimal(awardAmountInfo.getObligatedTotalDirect().doubleValue());
        obligatedTotalDirect = obligatedTotalDirect.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }//from ww  w. j av a 2  s .c  o  m
    return obligatedTotalDirect;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getObligatedChange() {
    BigDecimal obligatedChange = null;
    if (awardAmountInfo.getObligatedChange() != null) {
        obligatedChange = awardAmountInfo.getObligatedChange().bigDecimalValue();
        obligatedChange = obligatedChange.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from   w w w.  ja va  2s. com*/
    return obligatedChange;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getAnticipatedChange() {
    BigDecimal anticipatedChange = null;
    if (awardAmountInfo.getAnticipatedChange() != null) {
        anticipatedChange = awardAmountInfo.getAnticipatedChange().bigDecimalValue();
        anticipatedChange = anticipatedChange.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }//ww  w  .j  a  va  2 s  . com
    return anticipatedChange;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getObligatedDistributableAmt() {
    BigDecimal obligatedDistributableAmt = null;
    if (awardAmountInfo.getObliDistributableAmount() != null) {
        obligatedDistributableAmt = awardAmountInfo.getObliDistributableAmount().bigDecimalValue();
        obligatedDistributableAmt = obligatedDistributableAmt.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }// w  w  w.java2s.  c o  m
    return obligatedDistributableAmt;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getAmtObligatedToDate() {
    BigDecimal amtObligatedToDate = null;
    if (awardAmountInfo.getAmountObligatedToDate() != null) {
        amtObligatedToDate = awardAmountInfo.getAmountObligatedToDate().bigDecimalValue();
        amtObligatedToDate = amtObligatedToDate.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from  ww w .  j  a  va  2 s  .com*/
    return amtObligatedToDate;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getAntDistributableAmount() {
    BigDecimal anticipatedDistributableAmt = null;
    if (awardAmountInfo.getAntDistributableAmount() != null) {
        anticipatedDistributableAmt = awardAmountInfo.getAntDistributableAmount().bigDecimalValue();
        anticipatedDistributableAmt = anticipatedDistributableAmt.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from   w  ww . j a va2  s.c  o m*/
    return anticipatedDistributableAmt;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getAnticipatedTotalAmount() {
    BigDecimal anticipatedTotalAmt = null;
    if (awardAmountInfo.getAnticipatedTotalAmount() != null) {
        anticipatedTotalAmt = awardAmountInfo.getAnticipatedTotalAmount().bigDecimalValue();
        anticipatedTotalAmt = anticipatedTotalAmt.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from  w w w. j a  va2 s  . c  om*/
    return anticipatedTotalAmt;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private OtherHeaderDetails getOtherHeaderDetails() {
    OtherHeaderDetails otherHeaderDetails = OtherHeaderDetails.Factory.newInstance();
    if (award.getProposalNumber() != null) {
        otherHeaderDetails.setProposalNumber(award.getProposalNumber());
    }//from   w w  w. j  av  a 2 s.  co  m
    if (award.getAwardTypeCode() != null) {
        otherHeaderDetails.setAwardTypeCode(award.getAwardTypeCode());
    }
    if (award.getAwardTypeCode() != null) {
        if (prevAward != null && prevAward.getAwardTypeCode() != null) {
            String awardTypeDescription = getAwardTypeDesc(award.getAwardTypeCode());
            String prevAwardTypeDescription = getAwardTypeDesc(prevAward.getAwardTypeCode());
            String awardTypeDesc = getTypeDescription(awardTypeDescription, prevAwardTypeDescription);
            if (awardTypeDesc != null) {
                otherHeaderDetails.setAwardTypeDesc(awardTypeDesc);
            }
        } else {
            String awardTypeDesc = getAwardTypeDesc(award.getAwardTypeCode());
            if (awardTypeDesc != null) {
                otherHeaderDetails.setAwardTypeDesc(awardTypeDesc);
            }
        }
    }
    if (award.getSpecialEbRateOffCampus() != null) {
        otherHeaderDetails.setSpecialEBRateOffCampus(award.getSpecialEbRateOffCampus().bigDecimalValue());
    }
    if (award.getSpecialEbRateOnCampus() != null) {
        otherHeaderDetails.setSpecialEBRateOnCampus(award.getSpecialEbRateOnCampus().bigDecimalValue());
    }
    if (award.getAwardSpecialRate() != null && award.getAwardSpecialRate().getComments() != null) {
        otherHeaderDetails.setSpecialRateComments(award.getAwardBenefitsRateComment().getComments());
    }
    ScaleTwoDecimal bdecPreAwardAuthorizedAmt = award.getPreAwardAuthorizedAmount() == null
            ? ScaleTwoDecimal.ZERO
            : award.getPreAwardAuthorizedAmount();
    otherHeaderDetails.setPreAwardAuthorizedAmt(
            bdecPreAwardAuthorizedAmt.bigDecimalValue().setScale(2, BigDecimal.ROUND_HALF_DOWN));
    ScaleTwoDecimal bdecPreAwardAuthorizedAmtModified = award.getPreAwardInstitutionalAuthorizedAmount() == null
            ? ScaleTwoDecimal.ZERO
            : award.getPreAwardInstitutionalAuthorizedAmount();
    otherHeaderDetails.setPreAwardAuthorizedAmtModifeid(bdecPreAwardAuthorizedAmtModified.bigDecimalValue()
            .setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
    if (award.getPreAwardEffectiveDate() != null) {
        Calendar preAwardEffectiveDate = dateTimeService.getCalendar(award.getPreAwardEffectiveDate());
        otherHeaderDetails.setPreAwardEffectiveDate(preAwardEffectiveDate);
    }
    if (award.getPreAwardInstitutionalEffectiveDate() != null) {
        otherHeaderDetails.setPreAwardEffectiveDateModifeid(
                dateTimeService.toDateString(award.getPreAwardInstitutionalEffectiveDate()));
    }
    if (prevAward != null) {
        String preAwardAuthorizedAmtModified = getPreAwardAuthorizedAmountModified();
        if (preAwardAuthorizedAmtModified != null) {
            otherHeaderDetails.setPreAwardAuthorizedAmtModifeid(preAwardAuthorizedAmtModified);
        }
        String awardEffectiveDate = getPreAwardEffectiveDateModified();
        if (awardEffectiveDate != null) {
            otherHeaderDetails.setPreAwardEffectiveDateModifeid(awardEffectiveDate);
        }
        if (award.getCfdaNumber() != null && (prevAward.getCfdaNumber() == null
                || !award.getCfdaNumber().equals(prevAward.getCfdaNumber()))) {
            otherHeaderDetails.setCFDANumber(award.getCfdaNumber());
        }
        if (award.getSubPlanFlag() != null && (prevAward.getSubPlanFlag() != null
                || !award.getSubPlanFlag().equals(prevAward.getSubPlanFlag()))) {
            otherHeaderDetails.setSubPlan(award.getSubPlanFlag());
        }
        if (award.getPrimeSponsorCode() != null && (prevAward.getPrimeSponsorCode() == null
                || !award.getPrimeSponsorCode().equals(prevAward.getPrimeSponsorCode()))) {
            otherHeaderDetails.setPrimeSponsorCode(award.getPrimeSponsorCode());
        }
    } else {
        if (award.getCfdaNumber() != null) {
            otherHeaderDetails.setCFDANumber(award.getCfdaNumber());
        }
        if (award.getSubPlanFlag() != null) {
            otherHeaderDetails.setSubPlan(award.getSubPlanFlag());
        }
        if (award.getPrimeSponsorCode() != null) {
            otherHeaderDetails.setPrimeSponsorCode(award.getPrimeSponsorCode());
        }
    }

    if (award.getDocumentFundingId() != null) {
        otherHeaderDetails.setDFAFSNumber(award.getDocumentFundingId());
    }
    if (award.getProcurementPriorityCode() != null) {
        otherHeaderDetails.setProcurementPriorityCode(award.getProcurementPriorityCode());
    }
    if (award.getPrimeSponsor() != null && award.getPrimeSponsor().getSponsorName() != null) {
        otherHeaderDetails.setPrimeSponsorDescription(award.getPrimeSponsor().getSponsorName());
    }

    if (award.getBasisOfPaymentCode() != null) {
        otherHeaderDetails.setBasisPaymentCode(award.getBasisOfPaymentCode());
    }
    String basisPaymentDesc = getAwardBasisPaymentDesc();
    if (basisPaymentDesc != null) {
        otherHeaderDetails.setBasisPaymentDesc(basisPaymentDesc);
    }
    if (award.getMethodOfPaymentCode() != null) {
        otherHeaderDetails.setPaymentMethodCode(award.getMethodOfPaymentCode());
    }
    String paymentMethodDesc = getAwardPaymentMethodDesc();
    if (paymentMethodDesc != null) {
        otherHeaderDetails.setPaymentMethodDesc(paymentMethodDesc);
    }
    if (award.getActivityTypeCode() != null) {
        otherHeaderDetails.setActivityTypeCode(Integer.parseInt(award.getActivityTypeCode()));
        if (prevAward != null && prevAward.getActivityTypeCode() != null) {
            String activityTypeDescription = getActivityTypeDesc(String.valueOf(award.getActivityTypeCode()));
            String prevActivityypeDescription = getActivityTypeDesc(
                    String.valueOf(prevAward.getActivityTypeCode()));
            String activityTypeDesc = getTypeDescription(activityTypeDescription, prevActivityypeDescription);
            if (activityTypeDesc != null) {
                otherHeaderDetails.setActivityTypeDesc(activityTypeDesc);
            }
        } else {
            String activityTypeDesc = getActivityTypeDesc(String.valueOf(award.getActivityTypeCode()));
            if (activityTypeDesc != null) {
                otherHeaderDetails.setActivityTypeDesc(activityTypeDesc);
            }
        }
    }
    String invoiceInstructions = getInvoiceInstructionComments();
    if (invoiceInstructions != null) {
        otherHeaderDetails.setInvoiceInstructions(invoiceInstructions);
    }
    String fellowShipname = getFellowshipAdminName();
    if (fellowShipname != null) {
        otherHeaderDetails.setFellowshipAdminName(fellowShipname);
    }

    if (award.getAccountTypeCode() != null) {
        otherHeaderDetails.setAccountTypeCode(String.valueOf(award.getAccountTypeCode()));
    }
    if (award.getAccountTypeCode() != null)
        if (prevAward != null && prevAward.getAccountTypeCode() != null) {
            String accountTypeDescription = getAccountTypeDesc(String.valueOf(award.getAccountTypeCode()));
            String prevAccountTypeDescription = getAccountTypeDesc(
                    String.valueOf(prevAward.getAccountTypeCode()));
            String accountTypeDesc = getTypeDescription(accountTypeDescription, prevAccountTypeDescription);
            if (accountTypeDesc != null) {
                otherHeaderDetails.setAccountTypeDesc(accountTypeDesc);
            }
        } else {
            String accountTypeDescription = getAccountTypeDesc(String.valueOf(award.getAccountTypeCode()));
            if (accountTypeDescription != null) {
                otherHeaderDetails.setAccountTypeDesc(accountTypeDescription);
            }
        }
    AwardHierarchy hierarchy = award.getAwardHierarchyService()
            .loadAwardHierarchy(awardDocument.getAward().getAwardNumber());
    if (hierarchy != null) {
        AwardHierarchy parent = hierarchy.getParent();
        if (parent != null) {
            otherHeaderDetails.setRootAccountNumber(parent.getAward().getAccountNumber());
        } else {
            otherHeaderDetails.setRootAccountNumber(award.getAccountNumber());
        }
    }
    if (award.getUpdateUser() != null) {
        otherHeaderDetails.setUpdateUser(award.getUpdateUser());
    }
    if (award.getUpdateTimestamp() != null) {
        Calendar calendar = dateTimeService.getCalendar(award.getUpdateTimestamp());
        otherHeaderDetails.setLastUpdate(calendar);
    }
    return otherHeaderDetails;
}

From source file:org.onebusaway.api.actions.siri.impl.SiriSupportV2.java

public static boolean fillAnnotatedStopPointStructure(AnnotatedStopPointStructure annotatedStopPoint,
        StopRouteDirection stopRouteDirection, Map<Filters, String> filters, DetailLevel detailLevel,
        long currentTime) {

    StopBean stopBean = stopRouteDirection.getStop();
    List<RouteForDirection> routeDirections = stopRouteDirection.getRouteDirections();

    // Set Stop Name
    NaturalLanguageStringStructure stopName = new NaturalLanguageStringStructure();
    stopName.setValue(stopBean.getName());

    // Set Route and Direction
    Lines lines = new Lines();

    for (RouteForDirection routeDirection : routeDirections) {

        String directionId = routeDirection.getDirectionId();
        String routeId = routeDirection.getRouteId();

        LineRefStructure line = new LineRefStructure();
        line.setValue(routeId);//from  w ww.  java 2  s.  c  om

        DirectionRefStructure direction = new DirectionRefStructure();
        direction.setValue(directionId);

        LineDirectionStructure lineDirection = new LineDirectionStructure();
        lineDirection.setDirectionRef(direction);
        lineDirection.setLineRef(line);

        lines.getLineRefOrLineDirection().add(lineDirection);

    }

    // Set Lat and Lon
    BigDecimal stopLat = new BigDecimal(stopBean.getLat());
    BigDecimal stopLon = new BigDecimal(stopBean.getLon());

    LocationStructure location = new LocationStructure();
    location.setLongitude(stopLon.setScale(6, BigDecimal.ROUND_HALF_DOWN));
    location.setLatitude(stopLat.setScale(6, BigDecimal.ROUND_HALF_DOWN));

    // Set StopId
    StopPointRefStructure stopPointRef = new StopPointRefStructure();
    stopPointRef.setValue(stopBean.getId());

    // Details -- minimum
    annotatedStopPoint.getStopName().add(stopName);

    // Details -- normal
    if (detailLevel.equals(DetailLevel.NORMAL) || detailLevel.equals(DetailLevel.FULL)) {
        annotatedStopPoint.setLocation(location);
        annotatedStopPoint.setLines(lines);
        annotatedStopPoint.setMonitored(true);
    }

    annotatedStopPoint.setStopPointRef(stopPointRef);

    return true;
}