Example usage for java.lang StringIndexOutOfBoundsException getMessage

List of usage examples for java.lang StringIndexOutOfBoundsException getMessage

Introduction

In this page you can find the example usage for java.lang StringIndexOutOfBoundsException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

protected String getIntDecimalParts(final BigDecimal totalAmount) {
    String result = "";
    if (totalAmount != null) {
        String totalAmt = toCurrency(totalAmount.doubleValue());
        try {//w  w w  .  j  ava 2 s .c  o  m
            String intPart = totalAmt.substring(0, totalAmt.indexOf('.'));
            String decimalPart = totalAmt.substring(totalAmt.indexOf('.') + 1, totalAmt.length());
            result = intPart + ":" + decimalPart;
        } catch (final StringIndexOutOfBoundsException e) {
            logger.error("---totalAmt has no fractional part---" + e.getMessage());
            result = totalAmt + ":" + "00";
        }

    }
    return result;
}

From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java

protected PdfPTable createWorkValueDataTable() {
    final PdfPTable createWorkValueData = new PdfPTable(11);
    createWorkValueData.getDefaultCell().setBorderWidth(1);
    createWorkValueData.getDefaultCell().setColspan(7);
    createWorkValueData.addCell(makePara(pdfLabel.get("contractorbill.pdf.valueofworkdone")));

    createWorkValueData.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
    createWorkValueData.getDefaultCell().setColspan(1);
    final BigDecimal totalBillAmtUptBill = contractorBillService.getTotalValueWoForUptoBillDate(
            egBillRegister.getBilldate(), workOrderId, mbHeader.getWorkOrderEstimate().getId());

    if (totalBillAmtUptBill.compareTo(BigDecimal.ZERO) > 0) {
        final String totalBillAmt = toCurrency(totalBillAmtUptBill.doubleValue());
        try {//from   w  ww . jav a  2s  .  co  m
            createWorkValueData
                    .addCell(rightPara(blankSpace + totalBillAmt.substring(0, totalBillAmt.indexOf('.'))));
            createWorkValueData.addCell(centerPara(
                    blankSpace + totalBillAmt.substring(totalBillAmt.indexOf('.') + 1, totalBillAmt.length())));
        } catch (final StringIndexOutOfBoundsException e) {
            logger.error("----totalBillAmt has no fractional part----" + e.getMessage());
            createWorkValueData.addCell(centerPara(blankSpace + totalBillAmt));
            createWorkValueData.addCell("00");
        }

    } else {
        createWorkValueData.addCell(" ");
        createWorkValueData.addCell(" ");
    }

    BigDecimal billAmount = BigDecimal.ZERO;
    if (egBillRegister.getBillamount() != null)
        billAmount = egBillRegister.getBillamount();

    if (billAmount.compareTo(BigDecimal.ZERO) > 0) {
        final String billAmt = toCurrency(billAmount.doubleValue());
        try {
            createWorkValueData.addCell(centerPara(blankSpace + billAmt.substring(0, billAmt.indexOf('.'))));
            createWorkValueData.addCell(
                    centerPara(blankSpace + billAmt.substring(billAmt.indexOf('.') + 1, billAmt.length())));
        } catch (final StringIndexOutOfBoundsException e) {
            logger.error("---billAmt has no fractional part---" + e.getMessage());
            createWorkValueData.addCell(centerPara(blankSpace + billAmt));
            createWorkValueData.addCell("");
        }
    } else {
        createWorkValueData.addCell(" ");
        createWorkValueData.addCell(" ");
    }
    return createWorkValueData;
}