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 getExifDate(File imgFile) throws IOException {
    ExifInterface imgFileExif = new ExifInterface(imgFile.getCanonicalPath());

    if (imgFileExif.getAttribute(ExifInterface.TAG_DATETIME) != null) {
        String imgDateTime = imgFileExif.getAttribute(ExifInterface.TAG_DATETIME);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US);

        try {/* w w w .  j  ava2 s  .c  om*/
            return simpleDateFormat.parse(imgDateTime);

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

    return null;
}

From source file:Main.java

public static String formatTime_YYYYMMDD(String time) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    try {//from www .j  a v  a2 s .  c om
        return formatter.format(formatter.parse(time));
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static String formatTime(String time) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {//ww w.  j  a  v  a  2  s  . co  m
        return formatter.format(formatter.parse(time));
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";
    }
}

From source file:Main.java

public static Date parseRFC822Date(String date) {
    Date result = null;// w  ww .ja  va  2 s.  c  om
    if (date.contains("PDT")) {
        date = date.replace("PDT", "PST8PDT");
    }
    if (date.contains(",")) {
        // Remove day of the week
        date = date.substring(date.indexOf(",") + 1).trim();
    }
    SimpleDateFormat format = RFC822Formatter.get();
    for (int i = 0; i < RFC822DATES.length; i++) {
        try {
            format.applyPattern(RFC822DATES[i]);
            result = format.parse(date);
            break;
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    if (result == null) {
        Log.e(TAG, "Unable to parse feed date correctly");
    }

    return result;
}

From source file:Main.java

public static long getTime(String date) {
    try {/*from w ww.j a  v  a  2 s . co  m*/
        return simpleDateFormat.parse(date).getTime();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return -1;

}

From source file:Main.java

public static Date stringToDate(String strTime, String formatType) {
    SimpleDateFormat formatter = new SimpleDateFormat(formatType);
    Date date = null;/*www.  j av  a  2s. c o  m*/
    try {
        date = formatter.parse(strTime);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

public static Date dateJSONStringToDateOcupacioAules(String sDate) {
    Date date = null;/* w w  w .j  a  va  2  s  . c o m*/
    try {
        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        date = formatter.parse(sDate);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

public static Date convertStringToDate(String dateString) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss");
    Date date = null;/*from   ww  w  .  j  av  a  2 s .co m*/
    try {
        date = format.parse(dateString);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

static Date ConvertStringToDate(String dateString) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", java.util.Locale.getDefault());
    Date convertedDate = new Date();
    try {/*  w ww .  j ava 2 s .  c  o m*/
        convertedDate = dateFormat.parse(dateString);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return convertedDate;
}

From source file:Main.java

public static Date dateJSONStringToDateCorreu(String sDate) {
    Date date = null;/*from   w ww.  j av  a  2 s  .co  m*/
    try {
        SimpleDateFormat formatter = new SimpleDateFormat("\"dd/MM/yyyy HH:mm\"");
        date = formatter.parse(sDate);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}