Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.hp.mqm.clt.SettingsTest.java

@Test
public void testSettings_invalidIntegerValue() throws IOException, URISyntaxException {
    Settings settings = new Settings();
    try {/*from w w w.  j  a  va  2 s .co m*/
        settings.load(getClass().getResource("test.propertiesx").getPath());
        Assert.fail();
    } catch (NumberFormatException e) {
        Assert.assertEquals("For input string: \"invalid-integer\"", e.getMessage());
    }
}

From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java

private static Integer getId(String id) {
    Integer retId = null;// ww  w .j a va2 s.  c  o  m
    try {
        retId = Integer.parseInt(id);
    } catch (NumberFormatException e) {
        logger.error(e.getMessage());
        retId = 0;
    }
    return retId;
}

From source file:de.thorstenberger.examServer.webapp.action.TimeExtensionGlobalAction.java

@Override
public ActionForward execute(final ActionMapping mapping, final ActionForm form,
        final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    final ActionMessages errors = new ActionMessages();

    long taskId;/*from  ww w  .  jav a  2 s . co  m*/
    try {
        taskId = Long.parseLong(request.getParameter("taskId"));
    } catch (final NumberFormatException e) {
        errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("misc.error", e.getMessage()));
        saveErrors(request, errors);
        return mapping.findForward("success");
    }

    final TaskletContainer container = (TaskletContainer) getBean("TaskletContainer");

    final List<Tasklet> tasklets = container.getTasklets(taskId);
    for (Tasklet tasklet : tasklets) {
        if (tasklet.getStatus() == Status.INPROGRESS && tasklet instanceof ComplexTasklet) {
            final ComplexTasklet ct = (ComplexTasklet) tasklet;

            final Try activeTry = ct.getActiveTry();
            // increase time by 5 minutes
            // TODO make configurable
            activeTry.setTimeExtension(activeTry.getTimeExtension() + 5 * 60 * 1000);
            container.storeTasklet(tasklet);

            log.info(String.format("Increased time for student '%s' by 5min.", tasklet.getUserId()));

        }
    }
    return mapping.findForward("success");
}

From source file:gda.device.scannable.DummyContinuouslyScannable.java

@Override
public String checkPositionValid(Object illDefinedPosObject) {
    try {/* w  ww .j  a v  a  2 s  . c o  m*/
        Double.parseDouble(illDefinedPosObject.toString());
    } catch (NumberFormatException e) {
        return e.getMessage();
    }
    return null;
}

From source file:com.janrain.backplane2.server.MessageRequest.java

public MessageRequest(String callback, String since, String block) {

    if (StringUtils.isNotEmpty(callback)) {
        if (!callback.matches("[\\._a-zA-Z0-9]*")) {
            throw new InvalidRequestException("invalid_request", "Callback parameter value is malformed");
        }//from  w w w.  j a va  2 s .c o  m
    }

    this.since = StringUtils.isBlank(since) ? "" : since;

    try {
        Integer blockSeconds = Integer.valueOf(block);
        if (blockSeconds < 0 || blockSeconds > MAX_BLOCK_SECONDS) {
            throw new InvalidRequestException("Invalid value for block parameter (" + block
                    + "), must be between 0 and " + MAX_BLOCK_SECONDS);
        }
        this.returnBefore = new Date(System.currentTimeMillis() + blockSeconds.longValue() * 1000);
    } catch (NumberFormatException e) {
        throw new InvalidRequestException(
                "Invalid value for block parameter (" + block + "): " + e.getMessage());
    }

}

From source file:com.ctt.entity.Transaction.java

public Transaction(CSVRecord record) {
    try {//  w  w  w  .  j  a  v  a2 s. c  om
        System.out.println(record.get(0));
        String[] rr = record.get(0).split(";");

        System.out.println("0" + rr[0]);

        this.type_repayment = rr[0];

        this.type_id = rr[1];
        this.client_id = rr[2];
        this.value_transaction = Double.parseDouble(rr[3]);
        this.value_repayment = Double.parseDouble(rr[4]);
        this.tax = Double.parseDouble(rr[5]);
        this.type_tax = rr[6];
        this.code_bank = rr[7];
        this.card_number = rr[8];
        this.type_card = rr[9];

        this.isCreditCardTransaction = rr[10];

        this.dues = Integer.parseInt(rr[11]);

        if (rr.length >= 13)
            this.observations = rr[12];

    } catch (NumberFormatException ex) {
        Main.appendLog("Error: INIT TRANSACTION " + ex.getMessage());
    }

}

From source file:de.terrestris.shogun.deserializer.DateDeserializer.java

/**
 * Overwrite the deserializer for date strings in the form of a
 * unix timestamp (1293836400).//from w w w .  ja v a 2 s. c  o  m
 *
 * This method will also try to interpret strings like "30.04.2013 13:43:55"
 * as dates.
 */
@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext context)
        throws IOException, JsonProcessingException {

    Date deserializedDate = null;
    String s = jsonParser.getText();

    if (DateDeserializer.looksLikeFormattedDateString(s)) {
        deserializedDate = DateDeserializer.parseCommonlyFormattedDate(s);
    } else {
        String failNotice = "Failed to interpret string '" + s
                + "' as java.lang.Long. That string did not look like a " + "formatted date either.";
        try {
            Long number = new Long(s);
            deserializedDate = new Date(number);
        } catch (NumberFormatException e) {
            LOGGER.error(failNotice + " : " + e.getMessage());
        }
    }
    return deserializedDate;
}

From source file:de.hybris.platform.order.strategies.paymentinfo.impl.DefaultCreditCardNumberHelper.java

private boolean luhnTest(final String cardNumber) throws BusinessException {
    if (cardNumber == null) {
        return false;
    }// w  w  w.j  a  v  a 2 s.co m

    int len = cardNumber.length();
    final int digits[] = new int[len];
    for (int i = 0; i < len; i++) {
        try {
            digits[i] = Integer.parseInt(cardNumber.substring(i, i + 1));
        } catch (final NumberFormatException e) {
            LOG.error(e.getMessage());
            throw new BusinessException(e.getMessage(), e);
        }
    }
    int sum = 0;
    while (len > 0) {
        sum += digits[len - 1];
        len--;
        if (len > 0) {
            final int digit = 2 * digits[len - 1];
            sum += (digit > 9) ? digit - 9 : digit;
            len--;
        }
    }
    return (sum % 10 == 0);
}

From source file:org.bug4j.client.HttpConnector.java

private boolean createSession() {
    boolean ret = false;
    final String response = send("br/ses", ParamConstants.PARAM_APPLICATION_NAME, _applicationName,
            ParamConstants.PARAM_APPLICATION_VERSION, _applicationVersion, ParamConstants.PARAM_BUILD_DATE,
            Long.toString(_buildDate), ParamConstants.PARAM_DEV_BUILD, _devBuild ? "Y" : null,
            ParamConstants.PARAM_BUILD_NUMBER, _buildNumber == null ? null : Integer.toString(_buildNumber));
    if (response != null) {
        try {/*from ww w  . j av  a 2  s.  com*/
            _sessionId = Long.parseLong(response.trim());
            ret = true;
        } catch (NumberFormatException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    } else {
        _sessionId = -1;
    }
    return ret;
}

From source file:at.tuwien.minimee.migration.evaluators.ImageCompareEvaluator.java

public Double evaluate(String tempDir, String file1, String file2, String metric) {
    String commandTemplate = compareCommand.replace("%FILE1%", file1).replace("%FILE2%", file2);

    CommandExecutor cmdEx = new CommandExecutor();
    cmdEx.setWorkingDirectory(OS.getTmpPath());
    String command = commandTemplate.replace("%METRIC%", metric);
    try {/*w  w w.  ja  v  a2  s  . c  o  m*/
        cmdEx.runCommand(command);
        String out = cmdEx.getCommandError();
        log.debug(command + " == " + out);
        Double value = Scale.MAX_VALUE;

        try {
            if (out.contains(" ")) {
                out = out.substring(0, out.indexOf(" "));
            }
            value = Double.valueOf(out.trim());
        } catch (NumberFormatException e) {
            log.error("unknown numberformat: " + out + " " + e.getMessage());
        }
        return value;
    } catch (Exception e) {
        log.error("error during image comparison " + command + " : " + cmdEx.getCommandError(), e);
        return null;
    }
}