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 static Date parserData(String data) {
    try {/*from w ww . j  av a 2  s  . c o  m*/
        return new SimpleDateFormat("yyyy-MM-dd").parse(data);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static Date getDateFromString(String inputString) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    Date date = null;//  w ww. j  av  a 2 s.c  o  m
    try {
        date = sdf.parse(inputString);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

public static int compareDates(String dateTime1, String dateTime2, String format) {
    // 0 is equal, < 0 if date1 is less than date2
    try {//  www.  j  av  a2 s  . c o m
        SimpleDateFormat df = new SimpleDateFormat(format);
        Date date1 = df.parse(dateTime1);
        Date date2 = df.parse(dateTime2);
        return date1.compareTo(date2);

    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static String changeStringToDate2(String str) {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date date6 = null;//  w  w  w. ja  v  a2  s . c  om
    try {
        date6 = sdf.parse(str);
        java.sql.Date date7 = new java.sql.Date(date6.getTime());
        return date7.toString();
    } catch (ParseException e) {
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static String formatDateFromString(String input) {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    try {/*from w  w w.  j  av  a 2  s .com*/
        date = sdf.parse(input);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    sdf = new SimpleDateFormat("dd/MM/yyyy");
    String result = sdf.format(date);
    return result;
}

From source file:Main.java

public static String formatPublishedAt(String str) {
    //        yyyy-MM-dd'T'HH:mm:ss.SSSZ
    try {//w w  w  .  j  a v  a  2s .  c o  m
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        Date date = format.parse(str);

        DateFormat format2 = new SimpleDateFormat("yyyy/MM/dd");
        return format2.format(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

public static String getTimeFormatNO1(String time) {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    DateFormat wantdf = new SimpleDateFormat("yyyy-MM-dd");
    try {//from ww  w.  j av a2s .  co  m
        Date current = new Date();
        Date tiemBefore = df.parse(time.substring(0, 19).replace("T", " "));
        String str = wantdf.format(tiemBefore);
        return str;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return "null";
}

From source file:Main.java

public static String changeDateFormat(String string) {
    //1986-06-06//ww  w  .  j a v  a 2s.com
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();

    try {
        date = format.parse(string);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    format = new SimpleDateFormat("yyyy/MM/dd");
    return format.format(date);
}

From source file:Main.java

public static String ymdhm2Timestamp(String dateString) throws ParseException {
    String timeStamp = null;/*  ww w .j  a  va2  s . c o  m*/
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");
    Date d;
    try {
        d = sdf.parse(dateString);
        long l = d.getTime() / 1000;
        timeStamp = String.valueOf(l);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return timeStamp;
}

From source file:Main.java

public static Calendar parseCalendarString(String dateTimeString) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Date date = null;/* w  w w.j  a v a  2 s  .c o m*/
    try {
        date = dateFormat.parse(dateTimeString);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    Calendar cal = Calendar.getInstance();
    cal.setTimeZone(TimeZone.getTimeZone("Europe/Stockholm"));
    cal.setTime(date);
    return cal;
}