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 getTimeOfDate(String dateTime) {
    try {/*w  w  w .ja va  2  s .  c om*/
        Date parse = dateFormat.parse(dateTime);
        long time = parse.getTime();
        return time;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return 0;

}

From source file:Main.java

/**
 * To date string./*from   w  w w.ja  v a 2  s  .com*/
 *
 * @param date the date
 * @return the date
 */
@SuppressLint("SimpleDateFormat")
public static Date toDateString(String date) {
    String formatoFecha = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
    SimpleDateFormat sdf = new SimpleDateFormat(formatoFecha);
    sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
    try {
        return date == null ? null : sdf.parse(date);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

public static String getRelativeTimeAgo(String rawJsonDate) {
    String twitterFormat = "EEE MMM dd HH:mm:ss ZZZZZ yyyy";
    SimpleDateFormat sf = new SimpleDateFormat(twitterFormat, Locale.ENGLISH);
    sf.setLenient(true);//from ww w  . j av a2 s  .co  m

    String relativeDate = "";

    Date date;
    try {
        date = sf.parse(rawJsonDate);
        relativeDate = getTimeString(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return relativeDate;
}

From source file:Main.java

/**
 * Convert date into milliseconds./* w w w .j  av a2s  .  co m*/
 * 
 * @param crisisDate
 * @return
 */
public static long getMiliseconds(String crisisDate) {
    try {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        Date date = (Date) formatter.parse(crisisDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        return cal.getTimeInMillis();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return 0;
}

From source file:Main.java

public static boolean equalDate(String date) {
    Date todayDate = null;//from  w ww .  j  av a2s  .c om
    Date inputDate = null;
    Date thirdDate = null;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String today = sdf.format(new Date());
    Calendar cal = Calendar.getInstance();
    //      cal.add(Calendar.DATE, -1);      
    //      String today = sdf.format(cal.getTime());
    try {
        todayDate = sdf.parse(today);
        inputDate = sdf.parse(date);
        cal.setTime(inputDate);
        cal.add(Calendar.DATE, 3);
        thirdDate = cal.getTime();
        if (todayDate.compareTo(inputDate) >= 0 && todayDate.compareTo(thirdDate) < 0) {
            return true;
        } else {
            return false;
        }
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    }

}

From source file:com.jcalvopinam.utils.Utilities.java

/**
 * Convert date from String to Date object
 *
 * @param date/*from ww  w  . j  a  va  2 s. co  m*/
 * @return
 * @throws Exception
 */
public static Date matchDate(String date) {
    try {
        if (hasFormat(date)) {
            DateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
            return formatter.parse(date);
        }
    } catch (ParseException pe) {
        pe.printStackTrace();
    }
    return null;
}

From source file:com.surfs.storage.web.utils.Stringutils.java

public static String compareReturnBerfore(String baseDate, String strDate) {
    SimpleDateFormat sdf_us = new SimpleDateFormat("EEE MMM dd HH:mm yyyy", Locale.US);
    SimpleDateFormat sdf_cn = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    if (StringUtils.isBlank(baseDate)) {
        if (StringUtils.isBlank(strDate)) {
            return null;
        } else {/*from  w w w. j a  v a 2s .  c o m*/
            try {
                Date date = sdf_us.parse(strDate);
                return sdf_cn.format(date);
            } catch (ParseException e) {
                e.printStackTrace();
                return null;
            }
        }
    }

    try {
        /*String date_us1 = sdf_cn.format(sdf_us.parse(strDate1));*/
        String date_us2 = sdf_cn.format(sdf_us.parse(strDate));
        if (baseDate.compareTo(date_us2) <= 0)
            return baseDate;
        else if (baseDate.compareTo(date_us2) > 0)
            return date_us2;
    } catch (ParseException e) {
        e.printStackTrace();
        return null;
    }
    return strDate;
}

From source file:Main.java

public static String getLeftDay(String date) {
    if ("".equals(date) || date == null) {
        return "";
    }//from ww  w .j a  va2 s .c  o  m
    Date cur = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", getLocale());
    String curTime = sdf.format(cur);

    Date dt = new Date();
    long day = 0;
    try {
        dt = sdf.parse(curTime);
        long l = Long.parseLong(date) - dt.getTime();
        if (l > 0) {
            day = l / (24 * 60 * 60 * 1000);
        } else {
            day = 0;
        }
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NumberFormatException e) {
        e.printStackTrace();
    }

    return Long.toString(day);
}

From source file:Main.java

/**
 * @param dateStr/*from  w w w.  j a  v a 2  s .  c  o m*/
 *            "yyyy-MM-dd HH:mm:ss" like
 * @return parsed Date
 * @throws ParseException
 */
public static Date parseDetail(String dateStr) {
    DateFormat dateFormat = getDetailDateFormat();
    Date date = null;
    try {
        date = dateFormat.parse(dateStr);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}

From source file:Main.java

/**
 * @param dateStr/*from   w  ww . j  av  a  2  s.  c o m*/
 *            "yyyy-MM-dd" like
 * @return parsed Date
 * @throws ParseException
 */
public static Date parseSimple(String dateStr) {
    DateFormat dateFormat = getSimpleDateFormat();
    Date date = null;
    try {
        date = dateFormat.parse(dateStr);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return date;
}