Example usage for java.lang NumberFormatException getLocalizedMessage

List of usage examples for java.lang NumberFormatException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.openintents.safe.CryptoHelper.java

public static byte[] hexStringToBytes(String hex) {

    byte[] bytes = new byte[hex.length() / 2];
    int j = 0;/*from w  w w . j  a  v a  2 s . co m*/
    for (int i = 0; i < hex.length(); i += 2) {
        try {
            String hexByte = hex.substring(i, i + 2);

            Integer k = Integer.decode("0x" + hexByte);
            bytes[j++] = k.byteValue();
        } catch (NumberFormatException e) {
            Log.i(TAG, e.getLocalizedMessage());
            return bytes;
        } catch (StringIndexOutOfBoundsException e) {
            Log.i(TAG, "StringIndexOutOfBoundsException");
            return bytes;
        }
    }
    return bytes;
}

From source file:rs.metropolitan.data_changer.base.ToInteger.java

@Override
public Integer changeString(String data) {
    try {/* w w w. ja va2  s .c o  m*/
        String dot = ".";
        if (StringUtils.isNumeric(data) && StringUtils.countMatches(data, dot) == 0) {
            return new Integer(data);
        }
        return null;
    } catch (NumberFormatException ex) {
        System.err.print(ex.getLocalizedMessage());
        return null;
    } catch (Exception ex) {
        System.err.print(ex.getLocalizedMessage());
        return null;
    }
}

From source file:rs.metropolitan.data_changer.base.ToDouble.java

@Override
public Double changeString(String data) {
    try {/*from w  w w. j  a  va2s. c o m*/
        String dot = ".";
        String beforeDot = StringUtils.substringBefore(data, dot);
        String afterDot = StringUtils.substringBefore(data, dot);
        if (StringUtils.isNumeric(beforeDot) && StringUtils.isNumeric(afterDot)
                && StringUtils.countMatches(data, dot) == 1) {
            return new Double(data);
        }
        return null;
    } catch (NumberFormatException ex) {
        System.err.print(ex.getLocalizedMessage());
        return null;
    } catch (Exception ex) {
        System.err.print(ex.getLocalizedMessage());
        return null;
    }
}

From source file:org.kalypso.ogc.gml.gui.XsdDoubleGuiTypeHandler.java

@Override
public Object parseText(final String text, final String formatHint) throws ParseException {
    final String normalizedText = XsdFloatGuiTypeHandler.normalizeDecimalText(text);

    if (StringUtils.isBlank(normalizedText))
        return null;

    try {/*from  www. j a  va2  s .  c  o  m*/
        return Double.valueOf(normalizedText);
    } catch (final NumberFormatException e) {
        throw new ParseException(e.getLocalizedMessage(), 0);
    }
}

From source file:thobe.logfileviewer.server.EthSource.java

public static Arguments parseCommandLine(String args[]) {

    final String OPT_PORT = "p";
    final String OPT_FILE = "f";
    final String OPT_LPS = "l";
    final String OPT_INFINITE = "i";

    // create Options object
    Options options = new Options();

    @SuppressWarnings("static-access")
    Option optFilename = OptionBuilder.withArgName("filename").hasArg().withLongOpt("filename")
            .withDescription("Name of the file that should be read and send over socket.").create(OPT_FILE);

    @SuppressWarnings("static-access")
    Option optPort = OptionBuilder.withArgName("portnumber").hasArg().withLongOpt("port")
            .withDescription("The port to listen/send to.").create(OPT_PORT);

    @SuppressWarnings("static-access")
    Option optLPS = OptionBuilder.withArgName("lines per second").hasArg().withLongOpt("lps")
            .withDescription("The lines per second that should be published over eth by this source.")
            .create(OPT_LPS);/*from   w  ww .  j a v a 2s  .  c  o  m*/

    @SuppressWarnings("static-access")
    Option optInfinite = OptionBuilder.withArgName("infinite mode").hasArg(false).withLongOpt("inf")
            .withDescription("In infinite mode the file will be reopened after reaching eof.")
            .create(OPT_INFINITE);

    options.addOption(optFilename);
    options.addOption(optPort);
    options.addOption(optLPS);
    options.addOption(optInfinite);

    String filename = null;
    Integer port = null;
    int lps = 9500;
    boolean infiniteMode = false;
    try {
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);

        filename = cmd.getOptionValue(OPT_FILE);
        if (filename == null) {
            System.err.println("Filename is missing");
            usage(options);
            System.exit(1);
        }

        String portStr = cmd.getOptionValue(OPT_PORT);
        if (portStr == null) {
            System.err.println("Port is missing");
            usage(options);
            System.exit(1);
        }

        try {
            port = Integer.parseInt(portStr);
        } catch (NumberFormatException e) {
            System.err.println("Port is not a number");
            usage(options);
            System.exit(1);
        }

        String lpsStr = cmd.getOptionValue(OPT_LPS);
        if (lpsStr != null) {
            try {
                lps = Integer.parseInt(lpsStr);
            } catch (NumberFormatException e) {
                System.err.println("Ignore parameter '" + OPT_LPS + "' (lines per second) since '" + lpsStr
                        + "' is not a number");
            }
        }

        infiniteMode = cmd.hasOption(OPT_INFINITE);
    } catch (ParseException e) {
        System.err.println(e.getLocalizedMessage());
        usage(options);
        System.exit(2);
    }

    return new Arguments(filename, port, lps, infiniteMode);
}

From source file:org.kalypso.ogc.gml.gui.XsdFloatGuiTypeHandler.java

@Override
public Object parseText(final String text, final String formatHint) throws ParseException {
    final String normalizedText = XsdFloatGuiTypeHandler.normalizeDecimalText(text);

    if (StringUtils.isBlank(normalizedText))
        return null;

    try {//w  w  w . j  a  v  a 2  s  .  co m
        return Float.valueOf(normalizedText);
    } catch (final NumberFormatException e) {
        throw new ParseException(e.getLocalizedMessage(), 0);
    }
}

From source file:com.huateng.ebank.framework.util.DateUtil.java

/**
 * ???Calendar//from w  ww .  j  a v a2s .  co  m
 * @param date 8?14?
 * @return Calendar
 * @throws CommonException ?
 */
public static Calendar getCalFromDate(String date) throws CommonException {
    Calendar calendar = Calendar.getInstance();
    int year = 0;
    int month = 0;
    int date_of_month = 0;
    int hourOfDay = 0;
    int minute = 0;
    int second = 0;
    try {
        if (date.length() >= 8) {
            year = Integer.valueOf(date.substring(0, 4));
            month = Integer.valueOf(date.substring(4, 6)) - 1;
            date_of_month = Integer.valueOf(date.substring(6, 8));
        }
        if (date.length() >= 14) {
            hourOfDay = Integer.valueOf(date.substring(8, 10));
            minute = Integer.valueOf(date.substring(10, 12));
            second = Integer.valueOf(date.substring(12, 14));
        }
    } catch (NumberFormatException e) {
        ExceptionUtil.throwCommonException(e.getLocalizedMessage(), ErrorCode.ERROR_CODE_NORMAL, e);
    }
    calendar.set(year, month, date_of_month, hourOfDay, minute, second);
    calendar.set(Calendar.MILLISECOND, 0);
    return calendar;
}

From source file:org.kalypso.ogc.gml.gui.XsdDecimalGuiTypeHandler.java

@Override
public Object parseText(final String text, final String formatHint) throws ParseException {
    final String normalizedText = XsdFloatGuiTypeHandler.normalizeDecimalText(text);

    if (StringUtils.isBlank(normalizedText))
        return null;

    try {/*from w ww.j  a v  a  2s  . c o m*/
        return new BigDecimal(normalizedText);
    } catch (final NumberFormatException e) {
        throw new ParseException(e.getLocalizedMessage(), 0);
    }
}

From source file:org.opennms.netmgt.snmp.mock.PropertyOidContainer.java

public PropertyOidContainer(final Resource resource) throws IOException {
    MockSnmpValueFactory factory = new MockSnmpValueFactory();
    final Properties moProps = new Properties();
    InputStream inStream = null;//  ww  w.  j a  v  a 2 s. c  o  m
    try {
        inStream = resource.getInputStream();
        moProps.load(inStream);
    } finally {
        IOUtils.closeQuietly(inStream);
    }

    for (final Object obj : moProps.keySet()) {
        final String key = obj.toString();
        if (!key.startsWith("."))
            continue;
        final String value = moProps.getProperty(key);
        if (value.contains("No Such Object available on this agent at this OID")) {
            continue;
        }
        if (value.contains("No more variables left in this MIB View")) {
            continue;
        }
        //          LogUtils.debugf(this, "%s = %s", key, value);
        try {
            m_tree.put(SnmpObjId.get(key), factory.parseMibValue(value));
        } catch (final NumberFormatException nfe) {
            LOG.debug("Unable to store '{} = {}', skipping. ({})", key, value, nfe.getLocalizedMessage());
        }
    }
}

From source file:org.openestate.io.is24_csv.records.StellplatzKauf.java

public BigDecimal getHoehe() {
    try {//from   w w w . ja  va  2 s .  c om
        return Is24CsvFormat.parseDecimal(this.get(FIELD_HOEHE));
    } catch (NumberFormatException ex) {
        LOGGER.warn("Can't read 'Hoehe'!");
        LOGGER.warn("> " + ex.getLocalizedMessage(), ex);
        return null;
    }
}