Example usage for java.text ParseException toString

List of usage examples for java.text ParseException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.funambol.exchange.util.DateTools.java

public static Date pdiToGmtDate(String date) throws XmlParseException {
    SimpleDateFormat formatter;//w ww  .j a va2  s  .c  o  m
    Date dt;

    try {

        if (date != null) {

            formatter = new SimpleDateFormat(DATE_FORMAT_PDI);
            formatter.setTimeZone(TimeZone.getTimeZone("GMT"));

            dt = formatter.parse(date);
        } else {
            dt = null;
        }
    } catch (ParseException e) {
        throw new XmlParseException(e.toString());
    }

    return dt;

}

From source file:com.funambol.exchange.util.DateTools.java

/**
 * Make a date from a webdav tag date/*from w  w  w  .ja  v  a  2  s. com*/
 * 
 * @param date
 *            webdav tag content
 * @return a Date
 * @throws XmlParseException
 */
public static Date pdiToDate(String date) throws XmlParseException {

    SimpleDateFormat formatter;
    Date dt;

    try {

        if (date != null) {

            formatter = new SimpleDateFormat(DATE_FORMAT_PDI);

            dt = formatter.parse(date);
        } else {
            dt = null;
        }
    } catch (ParseException e) {
        throw new XmlParseException(e.toString());
    }

    return dt;

}

From source file:com.funambol.exchange.util.DateTools.java

/**
 * Make a date from a webdav tag date/*from  w w w  .j a v a  2  s  . co  m*/
 * 
 * @param date
 *            webdav tag content
 * @return a Date
 * @throws XmlParseException
 */
public static Date webDavTagToDate(String date) throws XmlParseException {

    SimpleDateFormat formatter;
    String value;
    Date timestamp;

    try {

        if (date != null && date.length() > 23) {
            value = date.substring(0, 10) + " " + date.substring(11, 23);

            formatter = new SimpleDateFormat(DATE_FORMAT_WEBDAV_FROM_EXCHANGE);
            formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
            timestamp = formatter.parse(value);
        } else {
            timestamp = null;
        }
    } catch (ParseException e) {
        throw new XmlParseException(e.toString());
    }

    return timestamp;

}

From source file:com.funambol.exchange.util.DateTools.java

/**
 * Make a date from a client date to webdav date
 * //from w  w  w  .j  a v a2 s.  c om
 * @param date
 *            client date
 * @return a Date
 * @throws XmlParseException
 */
public static Date clientDateToDate(String date) throws XmlParseException {

    SimpleDateFormat formatter;
    Date timestamp;

    String format;

    try {

        if (date != null) {

            if (date.indexOf("Z") != -1) {
                format = DATETIME_FORMAT_CLIENT_UTC;
            } else {
                //
                // for nokia phone utc bug
                //
                format = DATETIME_FORMAT_CLIENT_NO_UTC;
            }

            formatter = new SimpleDateFormat(format);
            formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
            timestamp = formatter.parse(date);

            return timestamp;

        } else {
            return null;
        }
    } catch (ParseException e) {
        throw new XmlParseException(e.toString());
    }
}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static Timestamp convertStringDateToTimestamp(String date, Locale locale) throws LIMSRuntimeException {
    String pattern = ResourceLocator.getInstance().getMessageResources().getMessage(locale,
            "dateTime.format.formatKey");

    SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
    Timestamp returnTimestamp = null;

    if (!StringUtil.isNullorNill(date)) {
        try {//from   w  w  w .  j  a va 2  s .c  om
            returnTimestamp = new Timestamp(format.parse(date).getTime());
        } catch (ParseException e) {
            LogEvent.logError("DateUtil", "convertStringDateToTimestamp()", e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnTimestamp;

}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static Timestamp convertStringDateToTruncatedTimestamp(String date, Locale locale)
        throws LIMSRuntimeException {
    String pattern = ResourceLocator.getInstance().getMessageResources().getMessage(locale,
            "date.format.formatKey");

    SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
    Timestamp returnTimestamp = null;

    if (!StringUtil.isNullorNill(date)) {
        try {//  ww w .j av  a  2s.c  o  m
            returnTimestamp = new Timestamp(format.parse(date).getTime());
        } catch (ParseException e) {
            LogEvent.logError("DateUtil", "convertStringDateToTimestamp()", e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnTimestamp;

}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static java.sql.Date convertStringDateTimeToSqlDate(String date) throws LIMSRuntimeException {
    String stringLocale = SystemConfiguration.getInstance().getDefaultLocale().toString();
    Locale locale = new Locale(stringLocale);
    String pattern = ResourceLocator.getInstance().getMessageResources().getMessage(locale,
            "dateTime.format.formatKey");
    SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
    java.sql.Date returnDate = null;
    if (!StringUtil.isNullorNill(date)) {
        try {/*from  w ww.  j a  v a  2 s.  com*/
            returnDate = new java.sql.Date(format.parse(date).getTime());
        } catch (ParseException e) {
            LogEvent.logError("DateUtil", "convertStringDateTimeToSqlDate()", e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnDate;

}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static java.sql.Date convertStringDateToSqlDate(String date, String stringLocale)
        throws LIMSRuntimeException {

    Locale locale = new Locale(stringLocale);
    String pattern = ResourceLocator.getInstance().getMessageResources().getMessage(locale,
            "date.format.formatKey");
    SimpleDateFormat format = new SimpleDateFormat(pattern, locale);
    format.setLenient(false);//from ww  w.  j  av  a  2  s .c o m
    java.sql.Date returnDate = null;

    if (!StringUtil.isNullorNill(date)) {
        try {
            returnDate = new java.sql.Date(format.parse(date).getTime());
        } catch (ParseException e) {
            // bugzilla 2154
            LogEvent.logError("DateUtil", "convertStringDateToSqlDate()", e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnDate;

}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static Timestamp convertStringDateToTimestampWithPatternNoLocale(String date, String pattern)
        throws LIMSRuntimeException {
    SimpleDateFormat format = new SimpleDateFormat(pattern);

    Timestamp returnTimestamp = null;
    if (!StringUtil.isNullorNill(date)) {
        try {//www . ja v a 2s.c o  m
            returnTimestamp = new Timestamp(format.parse(date).getTime());
        } catch (ParseException e) {
            LogEvent.logError("DateUtil",
                    "convertStringDateToTimestampWithPattern()\nPattern: " + pattern + "\nDate: " + date,
                    e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnTimestamp;

}

From source file:us.mn.state.health.lims.common.util.DateUtil.java

public static Timestamp convertStringDateToTimestampWithPattern(String date, String pattern)
        throws LIMSRuntimeException {
    Locale locale = SystemConfiguration.getInstance().getDateLocale();
    SimpleDateFormat format = new SimpleDateFormat(pattern, locale);

    Timestamp returnTimestamp = null;
    if (!StringUtil.isNullorNill(date)) {
        try {//w w w. jav  a2 s  .c  om
            returnTimestamp = new Timestamp(format.parse(date).getTime());
        } catch (ParseException e) {
            LogEvent.logError("DateUtil", "convertStringDateToTimestampWithPattern()\nlocale: " + locale
                    + "\nPattern: " + pattern + "\nDate: " + date, e.toString());
            throw new LIMSRuntimeException("Error parsing date", e);
        }
    }
    return returnTimestamp;

}