Example usage for java.math BigDecimal toString

List of usage examples for java.math BigDecimal toString

Introduction

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

Prototype

@Override
public String toString() 

Source Link

Document

Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.

Usage

From source file:com.netsteadfast.greenstep.bsc.command.KpiReportExcelCommand.java

private String getItemsContent(String name, float score, BigDecimal weight, float target, float min) {
    String str = "";
    str = name + "\n" + BscReportPropertyUtils.getScoreLabel() + " " + BscReportSupportUtils.parse2(score)
            + "\n" + BscReportPropertyUtils.getWeightLabel() + " " + weight.toString() + "%" + "\n"
            + BscReportPropertyUtils.getTargetLabel() + " " + target + "\n"
            + BscReportPropertyUtils.getMinLabel() + " " + min;
    return str;//from  w ww  .j ava 2s .  c o m
}

From source file:org.mifos.accounts.struts.action.ApplyAdjustment.java

@TransactionDemarcate(joinToken = true)
public ActionForward previewAdjustment(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form,
        HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    appAdjustActionForm.setAdjustData(!appAdjustActionForm.getAdjustcheckbox());

    if (appAdjustActionForm.isAdjustData()) {
        @SuppressWarnings("unchecked")
        List<ListItem<Short>> paymentTypes = (List<ListItem<Short>>) SessionUtils
                .getAttribute(MasterConstants.PAYMENT_TYPE, request);

        Short elementType = Short.valueOf(appAdjustActionForm.getPaymentType());
        for (ListItem<Short> item : paymentTypes) {
            if (item.getId().equals(elementType)) {
                SessionUtils.setAttribute(Constants.ADJUSTMENT_PAYMENT_TYPE, item.getDisplayValue(), request);
            }/*  w w w. ja  v a 2  s.c om*/
        }
    }

    if (appAdjustActionForm.getNewAmounts() != null && !appAdjustActionForm.getNewAmounts().isEmpty()) {
        BigDecimal newAmount = BigDecimal.ZERO;
        for (String memberNewAmountString : appAdjustActionForm.getNewAmounts().values()) {
            BigDecimal memberNewAmount = BigDecimal.ZERO;
            if (!StringUtils.isBlank(memberNewAmountString)) {
                memberNewAmount = new BigDecimal(memberNewAmountString);
            }
            newAmount = newAmount.add(memberNewAmount);
        }
        appAdjustActionForm.setAmount(newAmount.toString());
    }

    request.setAttribute("method", "previewAdjustment");
    return mapping.findForward("previewadj_success");
}

From source file:de.undercouch.bson4jackson.BsonGenerator.java

@Override
public void writeNumber(BigDecimal dec) throws IOException, JsonGenerationException {
    if (isEnabled(Feature.WRITE_BIGDECIMALS_AS_STRINGS)) {
        writeString(dec.toString());
        return;//from   w  w w  .  ja va  2 s . c om
    }

    float f = dec.floatValue();
    if (!Float.isInfinite(f)) {
        writeNumber(f);
    } else {
        double d = dec.doubleValue();
        if (!Double.isInfinite(d)) {
            writeNumber(d);
        } else {
            writeString(dec.toString());
        }
    }
}

From source file:com.netsteadfast.greenstep.bsc.command.KpiReportExcelCommand.java

private String getItemsContent(String name, float score, BigDecimal weight, float max, float target,
        float min) {
    String str = "";
    str = name + "\n" + BscReportPropertyUtils.getScoreLabel() + " " + BscReportSupportUtils.parse2(score)
            + "\n" + BscReportPropertyUtils.getWeightLabel() + " " + weight.toString() + "%" + "\n"
            + BscReportPropertyUtils.getMaxLabel() + " " + max + "\n" + BscReportPropertyUtils.getTargetLabel()
            + " " + target + "\n" + BscReportPropertyUtils.getMinLabel() + " " + min;
    return str;//w  w w . j a  v  a2 s.c  o m
}

From source file:com.xumpy.timesheets.services.TickedJobsDetailSrv.java

@Transactional(value = "transactionManager")
public Map<JobsGroupSrvPojo, Map<String, String>> tickedOverviewMonth(String month) throws ParseException {
    List<? extends Jobs> jobs = jobsDao.selectPeriode(CustomDateUtils.getFirstDayOfMonth(month),
            CustomDateUtils.getLastDayOfMonth(month));

    List<JobsGroup> jobsGroups = new ArrayList<JobsGroup>();
    for (Jobs job : jobs) {
        if (!jobsGroups.contains(job.getJobsGroup())) {
            jobsGroups.add(job.getJobsGroup());
        }// www. j a va2  s . com
    }

    Map<JobsGroupSrvPojo, Map<String, String>> returnMap = new HashMap<JobsGroupSrvPojo, Map<String, String>>();

    for (JobsGroup jobsGroup : jobsGroups) {
        BigDecimal actualWorked = new BigDecimal(0);
        BigDecimal timesheetWorked = new BigDecimal(0);

        Map worked = new HashMap<String, String>();

        for (Jobs job : jobs) {
            if (jobsGroup.getPk_id().equals(job.getJobsGroup().getPk_id())) {
                List<? extends TickedJobs> tickedJobs = tickedJobsDao.selectTickedJobsByJob(job.getPk_id());

                TickedJobsDetail jobsDetail = calculate(tickedJobs, new BigDecimal(30));

                timesheetWorked = timesheetWorked.add(job.getWorkedHours());
                actualWorked = actualWorked.add(jobsDetail.getActualWorked());
            }
        }
        worked.put("actualWorked", actualWorked.toString());
        worked.put("timesheetWorked", timesheetWorked.multiply(new BigDecimal(60)).toString());

        returnMap.put(new JobsGroupSrvPojo(jobsGroup), worked);
    }

    return returnMap;
}

From source file:oscar.oscarBilling.ca.on.data.RAData.java

public String getAmountPaid(ArrayList a) {
    BigDecimal total = new BigDecimal("0.00").setScale(2, BigDecimal.ROUND_HALF_UP);
    for (int i = 0; i < a.size(); i++) {
        Hashtable h = (Hashtable) a.get(i);
        BigDecimal valueToAdd = new BigDecimal("0.00");
        try {//from  ww w.j a  v  a 2s  .  c om
            String amount = "" + h.get("amountpay");
            amount = amount.trim();
            valueToAdd = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
        } catch (Exception badValueException) {
            MiscUtils.getLogger().debug(" Error calculating value for " + h.get("billing_no"));
            MiscUtils.getLogger().error("Error", badValueException);
        }
        total = total.add(valueToAdd);
    }
    return total.toString();
}

From source file:ru.neverdark.phototools.fragments.DofFragment.java

/**
 * @ return cirle of confusion for selected camera
 *//*from w  w  w  .j ava 2s.  co  m*/
private BigDecimal getCoc() {
    CameraData.Vendor vendor = (CameraData.Vendor) mWheelVendor.getSelectedItem();
    String camera = (String) mWheelCamera.getSelectedItem();
    BigDecimal coc = CameraData.getCocForCamera(vendor, camera);
    Log.variable("camera", camera);
    Log.variable("vendor", vendor.toString());

    if (Log.DEBUG) {
        if (coc != null) {
            Log.variable("coc", coc.toString());
        } else {
            Log.variable("coc", "null");
        }
    }

    return coc;
}

From source file:org.egov.ptis.actions.recovery.RecoveryAction.java

public String generateWarrantNotice() {
    LOGGER.debug("RecoveryAction | generateWarrantNotice | Start" + recovery.getWarrantNotice());
    String noticeNo = propertyTaxNumberGenerator.generateRecoveryNotice(PropertyTaxConstants.NOTICE156);
    recovery.getBasicProperty()//  w ww.jav  a2  s  .c  o m
            .setStatus(getPropStatusByStatusCode(PropertyTaxConstants.RECOVERY_WARRANTNOTICEISSUED));
    recovery.setStatus(getEgwStatusForModuleAndCode(PropertyTaxConstants.RECOVERY_MODULE,
            PropertyTaxConstants.RECOVERY_WARRANTNOTICEISSUED));
    updateWfstate("Notic 156 Generated");
    updateDemand(recovery);
    Map<String, Object> paramMap = getNotice156Param(recovery);
    PropertyTaxUtil propertyTaxUtil = new PropertyTaxUtil();
    Map<String, Map<String, BigDecimal>> reasonwiseDues = propertyTaxUtil
            .getDemandDues(recovery.getBasicProperty().getUpicNo());
    PropertyBillInfo propertyBillInfo = new PropertyBillInfo(reasonwiseDues, recovery.getBasicProperty(), null);
    String adress = recovery.getBasicProperty().getAddress().toString();
    BigDecimal totalRecoverAmt = propertyBillInfo.getGrandTotal()
            .add(BigDecimal.valueOf(Double.valueOf(paramMap.get("totalWarrantFees").toString()))).setScale(2);
    paramMap.put("adress", adress);
    paramMap.put("zoneNum", recovery.getBasicProperty().getPropertyID().getZone().getBoundaryNum().toString());
    paramMap.put("totalRecoverAmt", totalRecoverAmt.toString());
    ReportRequest reportRequest = new ReportRequest("Warrent", propertyBillInfo, paramMap);
    reportRequest.setPrintDialogOnOpenReport(true);
    ReportOutput reportOutput = reportService.createReport(reportRequest);
    reportId = addingReportToSession(reportOutput);
    if (reportOutput != null && reportOutput.getReportOutputData() != null) {
        InputStream Notice156PDF = new ByteArrayInputStream(reportOutput.getReportOutputData());
        PtNotice ptNotice = noticeService.saveNotice(null, noticeNo, PropertyTaxConstants.NOTICE156,
                recovery.getBasicProperty(), Notice156PDF);
        recovery.getWarrantNotice().setNotice(ptNotice);
    }
    LOGGER.debug("RecoveryAction | generateWarrantNotice | End" + recovery.getWarrantNotice());
    return PRINT;
}

From source file:act.reports.dao.AllInvoicesDAO.java

public String roundUp(float d, int decimalPlace) {
    BigDecimal bd = new BigDecimal(Float.toString(d));
    bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);
    return bd.toString();
}