Example usage for java.text ParseException fillInStackTrace

List of usage examples for java.text ParseException fillInStackTrace

Introduction

In this page you can find the example usage for java.text ParseException fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:com.hoiio.api.FaxAPI.java

private static Date parseDate(String date) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
    try {//from www.j  a v a2  s.  c om
        Date ans = formatter.parse(date.trim() + " SGT");
        return ans;
    } catch (ParseException ex) {

        formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
        try {
            Date ans = formatter.parse(date.trim() + " SGT");
            return ans;
        } catch (ParseException ex2) {
            log.error("Bug in Hoiio API - invalid date format: " + ex2.fillInStackTrace());
            return null;
        }
    }
}

From source file:uk.nhs.cfh.dsp.srth.query.converters.xml.impl.XMLToQueryExpressionTransformerImpl.java

/**
 * Gets the constraint value./*ww w  .  j ava2  s  . c o m*/
 *
 * @param element the element
 *
 * @return the constraint value
 */
public ConstraintValue<?> getConstraintValue(Element element) {

    logger.debug("Value of element.getName() : " + element.getName());
    ConstraintValue<?> constraintValue = null;
    String value = element.getAttributeValue("value");
    // create value based on attribute 'type'
    String type = element.getAttributeValue("type");
    if ("Integer".equals(type)) {
        int intValue = Integer.parseInt(value);
        constraintValue = new ConstraintValue<Integer>(intValue);
    } else if ("Double".equals(type)) {
        double doubleValue = Double.parseDouble(value);
        constraintValue = new ConstraintValue<Double>(doubleValue);
    } else if ("String".equals(type)) {
        constraintValue = new ConstraintValue<String>(value);
    } else if (type.indexOf("Calendar") > -1) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
        /*
        * we know that this is saved as yyyy-MM-ddThh:mm:ss
        * So we replace 'T' and all instances of ':' with '-'
        */
        String calString = value.replaceAll("T", "-");
        calString = calString.replaceAll(":", "-");

        try {
            Date date = sdf.parse(calString);
            Calendar cal = new GregorianCalendar();
            cal.setTime(date);

            constraintValue = new ConstraintValue<Calendar>(cal);
        } catch (ParseException e) {
            logger.warn(e.fillInStackTrace());
        }

    } else {
        logger.warn("Unknown constraint value type : " + type);
    }

    return constraintValue;
}