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

@SuppressLint("SimpleDateFormat")
public static Date StringToDate(String str) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
    Date date = null;//from  w ww.  j  ava 2s.  c  om
    try {
        date = sdf.parse(str);
    } catch (java.text.ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

/**
 * Gets the day of week out of a date.// w  w  w  .j av  a  2 s  . com
 *
 * @param dateString represents the date.
 * @return the day of week of the date.
 */
public static String dateToDayOfWeek(String dateString) {
    Date date = new Date();
    try {
        date = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.GERMAN).parse(dateString);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    DateFormat dtfmt = new SimpleDateFormat("EEE", Locale.ENGLISH);
    String dayOfWeek = dtfmt.format(date);
    return dayOfWeek;
}

From source file:Main.java

public static long parseYearMonthDay(String date) {
    try {//from  w w  w .  java2  s.  co  m
        return sYearMonthDaySdf.parse(date).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static long getActiveTimelong(String result) {
    try {//from ww w .j a va  2s.  c o m
        Date parse = yearFormat.parse(result);
        return parse.getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return System.currentTimeMillis();
}

From source file:Main.java

public static long getTempTime(String time) {
    try {/*  w ww.  j  ava  2 s.  com*/
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = simpleDateFormat.parse(time);
        long tempTime = date.getTime();
        return tempTime;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static long parseYearMonthDayHourMinute(String time) {
    try {/*from w  ww. ja v  a 2s.  c  om*/
        return sYearMonthDayHourMinuteSdf.parse(time).getTime();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static Date getDate(String dateStr, String format) {
    if (TextUtils.isEmpty(dateStr) || TextUtils.isEmpty(format)) {
        return null;
    }/*from   w ww  .  ja va 2s.  c  om*/
    Date date = null;
    try {
        SimpleDateFormat df = new SimpleDateFormat(format);
        date = df.parse(dateStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

/**
 * Permet de convertir une date du format annee-mois-jour 
 * en une instance de la classe java.util.Date
 * //from w  w  w. j a va2  s  . c  o m
 * @param stringDateFormat
 * @return
 */
public static Date toDate(String stringDateFormat) {
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    try {
        Date convertedDate = (Date) formatter.parse(stringDateFormat);
        return convertedDate;
    } catch (ParseException e) {

        e.printStackTrace();
    }

    return null;
}

From source file:Main.java

public static String FormatTime(String time) {
    if (time == null || time.equals("")) {
        return "";
    } else {/*from   ww  w .ja v a 2 s  .c o  m*/
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
        Date date = null;
        try {
            date = dateFormat.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
    }
}

From source file:Main.java

public static String parseDateToLongForm(String origDate) {
    DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
    Date date;//from   ww w  .  j a v  a 2  s . c om
    String newDate = "";
    try {
        date = formatter.parse(origDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        newDate = String.format("%1$tA, %1$tb %1$td, %1$tY", cal);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return newDate;
}