Example usage for java.lang NumberFormatException toString

List of usage examples for java.lang NumberFormatException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.ofbiz.service.job.JobInvoker.java

private long getTTL() {
    long ttl = THREAD_TTL;

    try {/*from   w  w  w.j a  va2 s  .  co m*/
        ttl = NumberUtils.toLong(ServiceConfigUtil.getElementAttr("thread-pool", "ttl"));
    } catch (NumberFormatException nfe) {
        Debug.logError(
                "Problems reading value from attribute [ttl] of element [thread-pool] in serviceengine.xml file ["
                        + nfe.toString() + "]. Using default (" + THREAD_TTL + ").",
                module);
    }
    return ttl;
}

From source file:org.patientview.patientview.ResultsAction.java

/**
 * Converts a set of patient results to JSON data suitable for Google Charts integration on clientside
 * @param resultData A collection of Result objects containing patient test results
 * @param resultType1 The name of the first set of results to convert
 * @param resultType2 The name of the first set of results to convert (deprecated)
 * @return A JSON format string containing formatted results data suitable for Google Charts
 *//*from   w ww  .  java2  s .  c  o m*/
private String convertToJsonData(Collection<Result> resultData, String resultType1, String resultType2) {

    ResultHeadingManager resultHeadingManager = getWebApplicationContext().getBean(ResultHeadingManager.class);
    String resultValue1 = "";
    String resultValue2 = "";

    ResultHeading heading1 = resultHeadingManager.get(resultType1);
    ResultHeading heading2 = resultHeadingManager.get(resultType2);

    StringBuffer sb = new StringBuffer();
    // cols header
    sb.append("{\"cols\":[");
    // DateTime
    sb.append("{\"id\":\"DateTime\",\"label\":\"DateTime\",\"type\":\"string\"},");

    if (StringUtils.isNotEmpty(resultType1)) {
        // result type 1
        sb.append("{\"id\":\"").append(heading1.getHeading()).append("\",");
        sb.append("\"label\":\"").append(heading1.getHeading()).append("\",").append("\"type\":\"number\"},");
        // tooltip for result type 1
        sb.append("{\"id\":\"\",").append("\"role\":\"tooltip\",").append("\"type\":\"string\",");
        sb.append("\"p\":{\"role\":\"tooltip\",\"html\":\"true\"}}");

        if (StringUtils.isEmpty(resultType2)) {
            sb.append("],");
        } else {
            sb.append(",");
        }
    }

    if (StringUtils.isNotEmpty(resultType2)) {

        // result type 2
        sb.append("{\"id\":\"").append(heading2.getHeading()).append("\",");
        sb.append("\"label\":\"").append(heading2.getHeading()).append("\",").append("\"type\":\"number\"},");
        // tooltip result type 2
        sb.append("{\"id\":\"\",").append("\"role\":\"tooltip\",").append("\"type\":\"string\",");
        sb.append("\"p\":{\"role\":\"tooltip\",\"html\":\"true\"}}],");
    }

    // rows value
    sb.append("\"rows\":[");

    Double resultHeadingMinValue = heading1.getMinRangeValue();
    Double resultHeadingMaxValue = heading1.getMaxRangeValue();
    Double dataMinValue = Double.MAX_VALUE;
    Double dataMaxValue = Double.MIN_VALUE;

    for (Iterator iterator = resultData.iterator(); iterator.hasNext();) {
        Result result = (Result) iterator.next();
        resultValue1 = result.getValue(resultType1);
        resultValue2 = result.getValue(resultType2);

        try {
            if (Double.parseDouble(resultValue1) < dataMinValue) {
                dataMinValue = Double.parseDouble(resultValue1);
            }
        } catch (NumberFormatException e) {
            LOGGER.trace("NumberFormatException: " + e.toString());
        } catch (NullPointerException e) {
            LOGGER.trace("NullPointerException: " + e.toString());
        }

        try {
            if (Double.parseDouble(resultValue1) > dataMaxValue) {
                dataMaxValue = Double.parseDouble(resultValue1);
            }
        } catch (NumberFormatException e) {
            LOGGER.trace("NumberFormatException: " + e.toString());
        } catch (NullPointerException e) {
            LOGGER.trace("NullPointerException: " + e.toString());
        }

        sb.append("{\"c\":[");
        // DateTime
        sb.append("{\"v\":\"").append(dateFormat.format(result.getTimeStamp().getTime())).append("\"},");

        if (StringUtils.isNotEmpty(resultType1)) {
            // result type 1
            sb.append("{\"v\":\"").append(resultValue1).append("\"},");
            // tooltip for result type 1
            sb.append("{\"v\":\"").append(getHtmlTooltip(result, heading1, resultValue1));
            sb.append("\"}");

            if (StringUtils.isNotEmpty(resultType2)) {
                sb.append(",");
            }
        }

        if (StringUtils.isNotEmpty(resultType2)) {
            // column 3: result type 2
            sb.append("{\"v\":\"").append(resultValue2).append("\"},");
            // tooltip for result type 2
            sb.append("{\"v\":\"").append(getHtmlTooltip(result, heading2, resultValue2)).append("\"}");
        }

        if (iterator.hasNext()) {
            sb.append("]},");
        } else {
            sb.append("]}");
        }
    }

    // min value and max value (for graph range) from either data or result heading defaults, store in config tag

    sb.append("],\"config\": {\"minRangeValue\" : \"");

    // for minimum graph y-axis value uses the lowest of either the data's range or the ResultHeading.minvalue
    if (resultHeadingMinValue != null) {
        if (dataMinValue != Double.MAX_VALUE) {
            if (dataMinValue < resultHeadingMinValue) {
                sb.append(dataMinValue);
            } else {
                sb.append(resultHeadingMinValue);
            }
        }
    } else {
        sb.append(dataMinValue);
    }

    sb.append("\", \"maxRangeValue\" : \"");

    // for maximum graph y-axis value uses the highest of either the data's range or the ResultHeading.maxvalue
    if (resultHeadingMaxValue != null) {
        if (dataMaxValue != Double.MIN_VALUE) {
            if (dataMaxValue > resultHeadingMaxValue) {
                sb.append(dataMaxValue);
            } else {
                sb.append(resultHeadingMaxValue);
            }
        }
    } else {
        sb.append(dataMaxValue);
    }

    // title text (first result heading)
    if (heading1.getHeading() != null) {
        sb.append("\", \"titleText\" : \"");
        sb.append(heading1.getHeading());
    }

    // units (y-axis label)
    if (heading1.getUnits() != null) {
        sb.append("\", \"units\" : \"");
        sb.append(heading1.getUnits());
    }

    sb.append("\"}}");
    return sb.toString();
}

From source file:us.mn.state.health.lims.sample.action.SampleLabelPrintProcessAction.java

protected ActionForward performAction(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    // The first job is to determine if we are coming to this action with an
    // ID parameter in the request. If there is no parameter, we are
    // creating a new Sample.
    // If there is a parameter present, we should bring up an existing
    // Sample to edit.
    String forward = FWD_SUCCESS;
    request.setAttribute(ALLOW_EDITS_KEY, "true");

    BaseActionForm dynaForm = (BaseActionForm) form;

    String numberOfSamples = (String) dynaForm.get("numberOfSamples");

    int count = 0;
    try {/*from w  w w .  j a v a 2  s  .c o m*/
        count = Integer.parseInt(numberOfSamples);
    } catch (NumberFormatException nfe) {
        //bugzilla 2154
        LogEvent.logError("SampleLabelPrintProcessAction", "performAction()", nfe.toString());
    }

    //      server-side validation (validation.xml)
    ActionMessages errors = dynaForm.validate(mapping, request);

    //bugzilla 2374 limit number of labels
    int maxNumberOfLabels = Integer.parseInt(SystemConfiguration.getInstance().getMaxNumberOfLabels());
    if (count > maxNumberOfLabels) {
        ActionError error = new ActionError("errors.labelprint.exceeded.maxnumber",
                SystemConfiguration.getInstance().getMaxNumberOfLabels(), null);
        errors.add(ActionMessages.GLOBAL_MESSAGE, error);
    }

    if (errors != null && errors.size() > 0) {
        saveErrors(request, errors);
        // since we forward to jsp - not Action we don't need to repopulate
        // the lists here
        return mapping.findForward(FWD_FAIL);
    }

    // initialize the form
    dynaForm.initialize(mapping);

    SampleLabelPrintProvider printProvider = new SampleLabelPrintProvider();
    Map parms = new HashMap();
    List listOfAccessionNumbers = new ArrayList();
    SampleDAO sampleDAO = new SampleDAOImpl();
    Sample sample = new Sample();
    Date today = Calendar.getInstance().getTime();
    Locale locale = (Locale) request.getSession().getAttribute("org.apache.struts.action.LOCALE");

    String dateAsText = DateUtil.formatDateAsText(today, locale);

    sample.setReceivedDateForDisplay(dateAsText);
    sample.setEnteredDateForDisplay(dateAsText);
    //      bgm - bugzilla 1586 remove setting collection date here in quick entry.
    // this will be set in HSE1.
    //sample.setCollectionDateForDisplay(dateAsText);

    //1926 get sysUserId from login module
    UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
    String sysUserId = String.valueOf(usd.getSystemUserId());
    //bgm added to see if this will fix the error for a record lock when this Sample is added here and
    // then updated later,within same thread, on another screen.... like in QuickEntry.
    Transaction tx = HibernateUtil.getSession().beginTransaction();

    try {
        //         bgm - bugzilla 1568 added sample.setStatus for lable printed.
        for (int i = 0; i < count; i++) {
            sample.setStatus(SystemConfiguration.getInstance().getSampleStatusLabelPrinted());
            //bugzilla 1926
            sample.setSysUserId(sysUserId);
            sampleDAO.insertData(sample);
            sampleDAO.getData(sample);

            //String stringToPrint = "^XA^FO5,40^BY3^BCN,100,Y,N,N^FD" + sample.getAccessionNumber() + "^FS^XZ\n";

            String accessionNumber = sample.getAccessionNumber();
            parms.put("Accession_Number", accessionNumber);
            listOfAccessionNumbers.add(accessionNumber);
            //parms.put("Accession_Number", stringToPrint);

            //bugzilla 2380
            if (!SystemConfiguration.getInstance().getLabelPrinterName().equalsIgnoreCase(NO_LABEL_PRINTING)
                    && !SystemConfiguration.getInstance().getLabelPrinterName().equals(BLANK)) {
                printProvider.processRequest(parms, request, response);
            }
        }

        tx.commit();

        //if it didn't fail then populate the accessionNumbersPrinted form field
        String accessionNumbersPrinted = "";
        String accessionNumberPrinted = "";
        //bugzilla 2380
        String accessionNumbersGenerated = "";
        String accessionNumberGenerated = "";

        if (!SystemConfiguration.getInstance().getLabelPrinterName().equalsIgnoreCase(NO_LABEL_PRINTING)
                && !SystemConfiguration.getInstance().getLabelPrinterName().equals(BLANK)) {
            if (listOfAccessionNumbers != null && listOfAccessionNumbers.size() > 0) {
                if (listOfAccessionNumbers.size() > 1) {
                    accessionNumbersPrinted = (String) listOfAccessionNumbers.get(0) + " - "
                            + (String) listOfAccessionNumbers.get(listOfAccessionNumbers.size() - 1);
                } else {
                    accessionNumberPrinted = (String) listOfAccessionNumbers.get(0);
                }

            }
            //bugzilla 2380
        } else {
            if (listOfAccessionNumbers != null && listOfAccessionNumbers.size() > 0) {
                if (listOfAccessionNumbers.size() > 1) {
                    accessionNumbersGenerated = (String) listOfAccessionNumbers.get(0) + " - "
                            + (String) listOfAccessionNumbers.get(listOfAccessionNumbers.size() - 1);
                } else {
                    accessionNumberGenerated = (String) listOfAccessionNumbers.get(0);
                }

            }
        }

        PropertyUtils.setProperty(form, "accessionNumbersPrinted", accessionNumbersPrinted);
        PropertyUtils.setProperty(form, "accessionNumberPrinted", accessionNumberPrinted);
        //bugzilla 2380
        PropertyUtils.setProperty(form, "accessionNumbersGenerated", accessionNumbersGenerated);
        PropertyUtils.setProperty(form, "accessionNumberGenerated", accessionNumberGenerated);

    } catch (LIMSRuntimeException lre) {
        //bugzilla 2154
        LogEvent.logError("SampleLabelPrintProcessAction", "performAction()", lre.toString());
        tx.rollback();

        errors = new ActionMessages();
        ActionError error = null;
        if (lre.getException() instanceof StaleObjectStateException) {
            error = new ActionError("errors.OptimisticLockException", null, null);
        }
        //bugzilla 2380
        else if (lre.getException() instanceof LIMSInvalidPrinterException) {
            error = new ActionError("errors.labelprint.invalidprinter",
                    SystemConfiguration.getInstance().getLabelPrinterName(), lre.getException().getMessage(),
                    null);
        } else {
            //bugzilla 2154
            LogEvent.logError("SampleLabelPrintProcessAction", "performAction()", lre.toString());
            error = new ActionError("errors.labelprint.general", null, null);
        }
        errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        saveErrors(request, errors);
        request.setAttribute(Globals.ERROR_KEY, errors);
        request.setAttribute(ALLOW_EDITS_KEY, "false");
        return mapping.findForward(FWD_FAIL);

    } finally {
        HibernateUtil.closeSession();
    }

    return mapping.findForward(forward);

}

From source file:us.mn.state.health.lims.testresult.action.TestResultUpdateAction.java

protected ActionMessages validateAll(HttpServletRequest request, ActionMessages errors, BaseActionForm dynaForm)
        throws Exception {

    // test validation against database
    String testNameSelected = (String) dynaForm.get("testName");

    if (!StringUtil.isNullorNill(testNameSelected)) {
        Test test = new Test();
        test.setTestName(testNameSelected);
        TestDAO testDAO = new TestDAOImpl();
        test = testDAO.getTestByName(test);

        String messageKey = "testresult.testName";

        if (test == null) {
            // the test is not in database - not valid
            // testName
            ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
            errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        }/*  w  w w .j a va 2s .  c  om*/
    }

    // scriptlet validation against database
    String scriptletSelected = (String) dynaForm.get("scriptletName");

    if (!StringUtil.isNullorNill(scriptletSelected)) {
        Scriptlet scriptlet = new Scriptlet();
        scriptlet.setScriptletName(scriptletSelected);
        ScriptletDAO scriptletDAO = new ScriptletDAOImpl();
        scriptlet = scriptletDAO.getScriptletByName(scriptlet);

        String messageKey = "testresult.scriptletName";

        if (scriptlet == null) {
            // the scriptlet is not in database - not valid
            // parentScriptlet
            ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
            errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        }
    }

    // validate for testResult D -> value must be dictionary ID
    String testResultType = (String) dynaForm.get("testResultType");

    if (testResultType.equals("D")) {
        String val = (String) dynaForm.get("value");
        String messageKey = "testresult.value";
        try {
            Integer.parseInt(val);

            Dictionary dictionary = new Dictionary();
            dictionary.setId(val);
            DictionaryDAO dictDAO = new DictionaryDAOImpl();
            List dictionarys = dictDAO.getAllDictionarys();

            boolean found = false;
            for (int i = 0; i < dictionarys.size(); i++) {
                Dictionary d = (Dictionary) dictionarys.get(i);
                if (dictionary.getId().equals(d.getId())) {
                    found = true;
                }
            }

            if (!found) {
                ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
                errors.add(ActionMessages.GLOBAL_MESSAGE, error);
            }
        } catch (NumberFormatException nfe) {
            //bugzilla 2154
            LogEvent.logError("TestResultUpdateAction", "validateAll()", nfe.toString());
            ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
            errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        }
    }

    return errors;
}

From source file:org.deviceconnect.message.http.impl.factory.HttpRequestMessageFactory.java

/**
 * HTTP???dConnect???./*from ww w  . j a  v a 2 s .c o m*/
 * @param dmessage dConnect
 * @param request HTTP
 */
protected void parseRequestQuery(final DConnectMessage dmessage, final HttpRequest request) {

    // parse query
    try {
        List<NameValuePair> query = URLEncodedUtils.parse(new URI(request.getRequestLine().getUri()), "UTF-8");

        if (query != null && query.size() > 0) {
            mLogger.fine("request query size: " + query.size());
            mLogger.fine("request query: " + query);
            for (NameValuePair pair : query) {
                mLogger.fine("request key/value: " + pair.getName() + ", " + pair.getValue());
                try {
                    dmessage.put(pair.getName(), Integer.parseInt(pair.getValue()));
                } catch (NumberFormatException e) {
                    dmessage.put(pair.getName(), pair.getValue());
                }
            }
        }
    } catch (URISyntaxException e) {
        mLogger.warning(e.toString());
    }

}

From source file:org.moqui.impl.context.L10nFacadeImpl.java

@Override
public Time parseTime(String input, String format) {
    Locale curLocale = getLocale();
    TimeZone curTz = getTimeZone();
    if (format == null || format.isEmpty())
        format = "HH:mm:ss.SSS";
    Calendar cal = calendarValidator.validate(input, format, curLocale, curTz);
    if (cal == null)
        cal = calendarValidator.validate(input, "HH:mm:ss", curLocale, curTz);
    if (cal == null)
        cal = calendarValidator.validate(input, "HH:mm", curLocale, curTz);
    if (cal == null)
        cal = calendarValidator.validate(input, "h:mm a", curLocale, curTz);
    if (cal == null)
        cal = calendarValidator.validate(input, "h:mm:ss a", curLocale, curTz);
    // also try the full ISO-8601, times may come in that way (even if funny with a date of 1970-01-01)
    if (cal == null)
        cal = calendarValidator.validate(input, "yyyy-MM-dd'T'HH:mm:ssZ", curLocale, curTz);
    if (cal != null) {
        Time time = new Time(cal.getTimeInMillis());
        // logger.warn("============== parseTime input=${input} cal=${cal} long=${cal.getTimeInMillis()} time=${time} time long=${time.getTime()} util date=${new java.util.Date(cal.getTimeInMillis())} timestamp=${new java.sql.Timestamp(cal.getTimeInMillis())}")
        return time;
    }//from   ww w .j  av a 2s  . c om

    // try interpreting the String as a long
    try {
        Long lng = Long.valueOf(input);
        return new Time(lng);
    } catch (NumberFormatException e) {
        if (logger.isTraceEnabled())
            logger.trace("Ignoring NumberFormatException for Time parse: " + e.toString());
    }

    return null;
}

From source file:org.moqui.impl.context.L10nFacadeImpl.java

@Override
public java.sql.Date parseDate(String input, String format) {
    if (format == null || format.isEmpty())
        format = "yyyy-MM-dd";
    Locale curLocale = getLocale();

    // NOTE DEJ 20150317 Date parsing in terms of time zone causes funny issues because the time part of the long
    //   since epoch representation is lost going to/from the DB, especially since the time portion is set to 0 and
    //   with time zone conversion when the system date is in an earlier time zone than the user date it pushes the
    //   Date to the previous day; what seems like the best solution is to parse and save the Date in the
    //   system/default time zone, and format it that way as well.
    // The BIG dilemma is there is no way to represent a Date (yyyy-MM-dd) in an object that does not use the long
    //   since epoch but rather is an absolute year, month, and day... which is really what we want.
    /*// w w w  . j a  v a 2s  .  c om
    TimeZone curTz = getTimeZone()
    Calendar cal = calendarValidator.validate(input, format, curLocale, curTz)
    if (cal == null) cal = calendarValidator.validate(input, "MM/dd/yyyy", curLocale, curTz)
    // also try the full ISO-8601, dates may come in that way
    if (cal == null) cal = calendarValidator.validate(input, "yyyy-MM-dd'T'HH:mm:ssZ", curLocale, curTz)
    */

    Calendar cal = calendarValidator.validate(input, format, curLocale);
    if (cal == null)
        cal = calendarValidator.validate(input, "MM/dd/yyyy", curLocale);
    // also try the full ISO-8601, dates may come in that way
    if (cal == null)
        cal = calendarValidator.validate(input, "yyyy-MM-dd'T'HH:mm:ssZ", curLocale);
    if (cal != null) {
        java.sql.Date date = new java.sql.Date(cal.getTimeInMillis());
        // logger.warn("============== parseDate input=${input} cal=${cal} long=${cal.getTimeInMillis()} date=${date} date long=${date.getTime()} util date=${new java.util.Date(cal.getTimeInMillis())} timestamp=${new java.sql.Timestamp(cal.getTimeInMillis())}")
        return date;
    }

    // try interpreting the String as a long
    try {
        Long lng = Long.valueOf(input);
        return new java.sql.Date(lng);
    } catch (NumberFormatException e) {
        if (logger.isTraceEnabled())
            logger.trace("Ignoring NumberFormatException for Date parse: " + e.toString());
    }

    return null;
}

From source file:com.streamsets.pipeline.stage.processor.fieldmask.FieldMaskProcessor.java

@Override
protected List<ConfigIssue> init() {
    List<ConfigIssue> issues = super.init();
    activeFieldMaskConfigs.clear();/*  w  w  w. j  av  a 2  s. c  om*/

    for (FieldMaskConfig fieldMaskConfig : allFieldMaskConfigs) {

        // Skip configurations with empty fields
        if (!fieldMaskConfig.fields.isEmpty()) {
            activeFieldMaskConfigs.add(fieldMaskConfig);
        }

        if (fieldMaskConfig.maskType == MaskType.REGEX) {
            Pattern p = Pattern.compile(fieldMaskConfig.regex);
            int maxGroupCount = p.matcher("").groupCount();
            if (maxGroupCount == 0) {
                issues.add(getContext().createConfigIssue(Groups.MASKING.name(), "groupsToShow", Errors.MASK_03,
                        fieldMaskConfig.regex));
            } else {
                regExToPatternMap.put(fieldMaskConfig.regex, p);
                if (fieldMaskConfig.groupsToShow == null || fieldMaskConfig.groupsToShow.trim().isEmpty()) {
                    issues.add(getContext().createConfigIssue(Groups.MASKING.name(), "groupsToShow",
                            Errors.MASK_02));
                    return issues;
                } else {
                    String[] groupsToShowString = fieldMaskConfig.groupsToShow.split(",");
                    Set<Integer> groups = new HashSet<>();
                    for (String groupString : groupsToShowString) {
                        try {
                            int groupToShow = Integer.parseInt(groupString.trim());
                            if (groupToShow <= 0 || groupToShow > maxGroupCount) {
                                issues.add(getContext().createConfigIssue(Groups.MASKING.name(), "groupsToShow",
                                        Errors.MASK_01, groupToShow, fieldMaskConfig.regex, maxGroupCount));
                            }
                            groups.add(groupToShow);
                        } catch (NumberFormatException e) {
                            issues.add(getContext().createConfigIssue(Groups.MASKING.name(), "groupsToShow",
                                    Errors.MASK_01, groupString, fieldMaskConfig.regex, maxGroupCount,
                                    e.toString(), e));
                        }
                    }
                    regexToGroupsToShowMap.put(fieldMaskConfig.regex, groups);
                }
            }
        }
    }

    fieldPathEval = getContext().createELEval("fields");
    fieldPathVars = getContext().createELVars();

    return issues;
}

From source file:org.moqui.impl.context.L10nFacadeImpl.java

@Override
public Timestamp parseTimestamp(String input, String format) {
    if (input == null || input.isEmpty())
        return null;
    Locale curLocale = getLocale();
    TimeZone curTz = getTimeZone();
    Calendar cal = null;//w ww  .j  ava  2  s.c  o  m
    if (format != null && !format.isEmpty())
        cal = calendarValidator.validate(input, format, curLocale, curTz);

    // long values are pretty common, so if there are no special characters try that first (fast to check)
    if (cal == null) {
        int nonDigits = StupidUtilities.countChars(input, false, true, true);
        if (nonDigits == 0) {
            try {
                Long lng = Long.valueOf(input);
                return new Timestamp(lng);
            } catch (NumberFormatException e) {
                if (logger.isTraceEnabled())
                    logger.trace("Ignoring NumberFormatException for Timestamp parse: " + e.toString());
            }
        }
    }

    // try a bunch of other format strings
    if (cal == null) {
        int timestampFormatsSize = timestampFormats.size();
        for (int i = 0; cal == null && i < timestampFormatsSize; i++) {
            String tf = timestampFormats.get(i);
            cal = calendarValidator.validate(input, tf, curLocale, curTz);
        }
    }

    // logger.warn("=========== input=${input}, cal=${cal}, long=${cal?.getTimeInMillis()}, locale=${curLocale}, timeZone=${curTz}, System=${System.currentTimeMillis()}")
    if (cal != null)
        return new Timestamp(cal.getTimeInMillis());

    try {
        // NOTE: do this AFTER the long parse because long numbers are interpreted really weird by this
        // ISO 8601 parsing using JAXB DatatypeConverter.parseDateTime(); on Java 7 can use "X" instead of "Z" in format string, but not in Java 6
        cal = DatatypeConverter.parseDateTime(input);
        if (cal != null)
            return new Timestamp(cal.getTimeInMillis());
    } catch (Exception e) {
        if (logger.isTraceEnabled())
            logger.trace("Ignoring Exception for DatatypeConverter Timestamp parse: " + e.toString());
    }

    return null;
}

From source file:com.deafgoat.ml.prognosticator.Charter.java

/**
 * Creates data set containing numeric attributes along with prediction
 * confidence/* w w  w  .  j  av a2s.co m*/
 * 
 * @param files
 *            List of files containing predictions to chart
 * @return the series collection to chart
 */
private XYSeriesCollection createNumericDataset(String[] files) {
    _logger.info("Collating data");
    BufferedReader br = null;
    XYSeries prediction = null;
    final XYSeriesCollection dataset = new XYSeriesCollection();
    for (String dataFile : files) {
        try {
            String sCurrentLine;
            br = new BufferedReader(new FileReader(dataFile));
            prediction = new XYSeries(dataFile);
            while ((sCurrentLine = br.readLine()) != null) {
                String[] data = sCurrentLine.split("\t");
                try {
                    prediction.add(Double.parseDouble(data[1]), Double.parseDouble(data[2]));
                } catch (NumberFormatException e) {
                    continue;
                }
            }
        } catch (IOException e) {
            _logger.error(e.toString());
        } finally {
            try {
                if (br != null) {
                    br.close();
                }
            } catch (IOException e) {
                _logger.error(e.toString());
            }
        }
        if (prediction != null) {
            dataset.addSeries(prediction);
        }
    }
    return dataset;
}