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 long getTime(String time, String pattern) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    try {/*from w  w  w.  jav a2s .  c o m*/
        return simpleDateFormat.parse(time).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static boolean isBeforeTime(String date1, String date2) {
    try {/*from w  ww.  j ava  2  s  . co m*/
        SimpleDateFormat dfDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dfDateFormat.parse(date1).before(dfDateFormat.parse(date2));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static Date getFormattedDate(String dateString) {
    try {/*  w  w  w. jav  a  2s.  com*/
        return dateFormat.parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    throw new IllegalArgumentException("Invalid date string " + dateString);
}

From source file:Main.java

public static Date parseDateToString(String inputDate, String datePattern) {
    DateFormat dateFormat = new SimpleDateFormat(datePattern);
    try {//from   w w w .  j  av  a  2s . c o  m
        return dateFormat.parse(inputDate);
    } catch (ParseException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static Date stringToDate(String dateString) {
    try {//from ww  w. jav  a2s . com
        return sdf.parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
        return new Date(0);
    }
}

From source file:Main.java

public static long parse(String time) {
    try {/*from   w  w w  .  j  a v  a2s .  com*/
        return timeFormat.parse(time).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static Date getDateFromString(String date, String format) {
    try {/*w  w  w.j a  v  a2 s .  c  o m*/
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.parse(date);
    } catch (ParseException p) {
        p.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static long getMillisTimeStr(String time, String pattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    try {/* w w w  .ja  v a  2  s . c om*/
        long millis = sdf.parse(time).getTime();
        return millis;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return -1;
}

From source file:Main.java

public static long date2millis(String pattern, String date) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    long millis = 0L;
    try {//from   w ww . j a  v a2  s  .c om
        millis = sdf.parse(date).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return millis;
}

From source file:Main.java

public static void setIsbnMask(JFormattedTextField textField) {
    try {//from  ww w.ja v  a  2  s.c  om
        MaskFormatter mask = new MaskFormatter("###-#-##-######-#");
        textField.setFormatterFactory(new DefaultFormatterFactory(mask));
    } catch (ParseException e) {
        e.printStackTrace();
    }
}