Example usage for java.text ParseException printStackTrace

List of usage examples for java.text ParseException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public synchronized static String formatDisplayActivityDate(String date) {
    String formattedDateDisplay = "";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date dateFormat = null;//from  w  ww  . ja  v  a 2  s.  com
    try {
        dateFormat = sdf.parse(date);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    SimpleDateFormat sdf2 = new SimpleDateFormat("MM/dd/yyyy");
    formattedDateDisplay = sdf2.format(dateFormat);

    String[] dateTimeArray = formattedDateDisplay.split("T");

    return formattedDateDisplay;
}

From source file:Main.java

/**
 * Converts a node to a double//  w w  w  .  ja va  2  s.  com
 * 
 * @param node
 *            The node to be parsed
 * @return The obtained value
 */
protected static Double nodeToDouble(Node node) {
    Double returnValue = null;
    try {
        String nodeValue = node.getFirstChild().getNodeValue();
        nodeValue = nodeValue.trim();
        returnValue = nf.parse(nodeValue).doubleValue();
    } catch (ParseException e) {
        // Should never happen
        e.printStackTrace();
    }

    return returnValue;
}

From source file:Main.java

public static Date string2Date(String sd, String formato) {
    //formato = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    //"Thu Jul 11 12:40:18 GMT-03:00 2013"
    //"EE MMM dd HH:mm:ss z YYYY"
    SimpleDateFormat format = new SimpleDateFormat(formato);
    try {//from w w w  . jav  a  2 s .  com
        Date date = (Date) format.parse(sd);
        return date;
    } catch (ParseException e) {
        // TODO Auto-generated catch block  
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static long getGMTTime(String strGMTTime) {
    long millisecond = 0;
    try {/*from  ww  w .  j  ava  2  s.c  o  m*/
        millisecond = GMTTimeFormatter.parse(strGMTTime).getTime();
    } catch (ParseException e) {
        if (strGMTTime.length() > 0)
            e.printStackTrace();
        else
            System.err.println(e.getMessage());
    }
    return millisecond;
}

From source file:Main.java

public static String formatJsonDate(String jd) {
    sdfgmt.setTimeZone(TimeZone.getTimeZone("GMT"));
    sdfest.setTimeZone(TimeZone.getTimeZone("US/Eastern"));

    String stripped = jd.substring(0, 19).replace('T', ' ');
    Date date = new Date();

    try {/*from   w  w  w .j a  v  a2s.com*/
        date = sdfgmt.parse(stripped);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    String result = sdfest.format(date);

    return result;
}

From source file:Main.java

public static boolean expireDate(String date) {
    Date todayDate = null;/*from ww  w  . ja  va2s  .  co m*/
    Date inputDate = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String today = sdf.format(new Date());
    try {
        todayDate = sdf.parse(today);
        inputDate = sdf.parse(date);
        if (todayDate.compareTo(inputDate) <= 0) {
            return false;
        } else {
            return true;
        }
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    }

}

From source file:Main.java

public static Date combineDateTime(Date date, Date time) {

    SimpleDateFormat timeF = new SimpleDateFormat("HH-mm");
    SimpleDateFormat dateF = new SimpleDateFormat("DD-MM-yyyy");
    SimpleDateFormat dateTimeF = new SimpleDateFormat("DD-MM-yyyy-HH-mm");

    String dateStr = dateF.format(date);
    String timeStr = timeF.format(time);
    String result = dateStr + "-" + timeStr;

    Date resultDateTime = null;//from   ww w .  java  2 s .  c  o m

    try {
        resultDateTime = dateTimeF.parse(result);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return resultDateTime;
}

From source file:Main.java

public static Date getDate(String crisisDate) {
    try {//from   www.jav a  2s.c o  m
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        Date date = (Date) formatter.parse(crisisDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.getTime();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:com.hackathon.gavin.currency.event.CurrencyEventCreater.java

/**
 * This method is used to convert RFC3339 format to normal date
 *
 * @param dateString in RFC3339 format/*from w ww . j a  va2s.  co  m*/
 * @return date in java.util.Date format
 * @throws java.text.ParseException
 * @throws IndexOutOfBoundsException
 */
public static Date parseRFC3339Date(String dateString)
        throws java.text.ParseException, IndexOutOfBoundsException {

    Date currentDate = new Date();

    if (dateString.endsWith("Z")) {
        try {
            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
            currentDate = s.parse(dateString);
        } catch (java.text.ParseException pe) {
            pe.printStackTrace();
        }
        return currentDate;
    }

    return currentDate;
}

From source file:Main.java

public static long getCurrentDayTime() {
    Date d = new Date(System.currentTimeMillis());
    String formatDate = yearFormat.format(d);
    try {/*w ww.j  a  v  a 2 s  .  c  om*/
        return (yearFormat.parse(formatDate)).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}