List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date parseDate(String date) { Date mDate = null;//from www. j av a 2 s . co m try { mDate = formatDate.parse(date); } catch (ParseException e) { e.printStackTrace(); } return mDate; }
From source file:Main.java
public static long parseDateTime(String dateTime) { if (TextUtils.isEmpty(dateTime)) { return 0; }// w w w. j ava2s . c o m long time = 0; try { Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateTime); if (null != date) { time = date.getTime(); } } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static Date getDateByFormat(String strDate, String format) { SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format); Date date = null;/* www . j a va 2 s . co m*/ try { date = mSimpleDateFormat.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date parseDateTime(String datetime) { Date mDate = null;/* w w w. ja v a 2s.com*/ try { mDate = formatDateTime.parse(datetime); } catch (ParseException e) { e.printStackTrace(); } return mDate; }
From source file:Main.java
public static Date strToDate(String dateString) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzzZ yyyy", Locale.ENGLISH); Date date = null;/* w w w . j av a2 s . c om*/ try { date = simpleDateFormat.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static String timeToDeparture(String startTime) { int diffMinutes = -1; Calendar now = Calendar.getInstance(); now.setTime(new Date()); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Date date = null;//w w w.j a v a 2 s. c om try { date = dateFormat.parse(startTime); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); cal.setTime(date); long millisDiff = cal.getTimeInMillis() - now.getTimeInMillis(); if (millisDiff > 0) { diffMinutes = ((int) millisDiff / (60 * 1000)); } return String.valueOf(diffMinutes); }
From source file:Main.java
public static boolean isSameDay(String time1, String time2) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try {//from w ww .j a v a 2s. com Date date1 = sdf.parse(time1); Date date2 = sdf.parse(time2); return sdf.format(date1).equals(sdf.format(date2)); } catch (ParseException e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static Date stringToDateTime(String strDate) { if (strDate != null) { try {/*from w w w.j a va 2 s .c o m*/ return SDF.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } } return null; }
From source file:Main.java
public static String StandardFormatStr(String str) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {/*from w w w . j a v a 2 s . com*/ Date d = sdf.parse(str); long timeStamp = d.getTime(); long curTime = System.currentTimeMillis() / (long) 1000; long time = curTime - timeStamp / 1000; return time / 60 + ""; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
private static Date stringToDateTime(String strDate) { if (strDate != null) { try {//from ww w. j ava2 s .co m return sdf.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } } return null; }