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:com.heren.turtle.server.utils.SampleDateUtils.java

public static Date getDate(String dateStr, String pattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    Date parseDate = null;/*w  w w  .  j  a v  a 2s  .c om*/
    try {
        parseDate = sdf.parse(dateStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return parseDate;
}

From source file:Main.java

public static boolean isToDay(Date date) {
    DateFormat dateFormat = DateFormat.getDateInstance();
    String format = dateFormat.format(new Date());
    try {/*w w  w  .j a  v  a 2 s. co m*/
        Date today = dateFormat.parse(format);
        return today.before(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:Main.java

public static Date getDateFromString(String date) {
    SimpleDateFormat sf = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZZZ yyyy");
    sf.setLenient(true);//from   w w  w.j  a v  a2 s.  c o  m
    Date ret = new Date();
    try {
        ret = sf.parse(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return ret;
}

From source file:Main.java

public static int compare(String s1, String s2) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
    try {/*  w  ww. j  a  v a 2 s  .c  o  m*/
        Date d1 = format.parse(s1);
        Date d2 = format.parse(s2);
        return d1.compareTo(d2);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return -1;
}

From source file:Main.java

public static Date convertDateTimeToDate(String dateTime) {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS", Locale.ENGLISH);
    Date date = null;/* w ww  .  j  a v a2s . c o m*/
    try {
        date = format.parse(dateTime);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    //        System.out.println(date);
    return date;
}

From source file:Main.java

public static Date getDateFromString(String date, String pattern) {
    Date dateObj = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    try {/*from   w w  w.jav a2  s . co m*/
        dateObj = sdf.parse(date);
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dateObj;
}

From source file:Main.java

public static Date parseDateString(String dateString) {
    // "2014-04-26 09:00:22"
    Date date = null;//www  . j a v  a 2  s  .co  m
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.US);
    try {
        date = dateFormat.parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

public static String changeStringToDate1(String str) {

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date date6 = null;/* w  ww  .ja v a  2s.  c  o m*/
    try {
        date6 = sdf.parse(str);
        return date6.toString();
    } catch (ParseException e) {
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static String normalizeDate(String rDate) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd", Locale.US);
    Date date = null;//  www . j  a  v  a 2s  .  c om
    try {
        date = simpleDateFormat.parse(rDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return DateFormat.getDateInstance(DateFormat.LONG).format(date);
}

From source file:Main.java

public static Date stringToDate(String str, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    Date date = null;//w w w .j a  va 2 s .c o  m
    try {
        date = sdf.parse(str);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}