List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date getDateTime(String date) { Date originalReleaseDate = null; try {/* w w w . ja v a 2 s. co m*/ if (!TextUtils.isEmpty(date)) { originalReleaseDate = dateTimeFormat.parse(date); } } catch (ParseException e) { e.printStackTrace(); } return originalReleaseDate; }
From source file:Main.java
public static String ymd2Timestamp(String dateString) throws ParseException { String timeStamp = null;/* w ww .j av a 2 s . c om*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date d; try { d = sdf.parse(dateString); long l = d.getTime() / 1000; timeStamp = String.valueOf(l); } catch (ParseException e) { e.printStackTrace(); } return timeStamp; }
From source file:Main.java
public static Date getDateByFormatDate(String dateString, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); Date date = null;/* ww w .j a va2s . c o m*/ try { date = dateFormat.parse(dateString); } catch (ParseException exception) { exception.printStackTrace(); } return date; }
From source file:Main.java
public static String readableDate(String dateString) { DateFormat input = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"); DateFormat output = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date date = new Date(); try {//from ww w . j ava2 s . com date = input.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return output.format(date.getTime()); }
From source file:Main.java
public static long formatToLong(String time, String template) { SimpleDateFormat sdf = new SimpleDateFormat(template, Locale.CHINA); try {/*from ww w . j a v a 2s. c o m*/ Date d = sdf.parse(time); Calendar c = Calendar.getInstance(); c.setTime(d); long l = c.getTimeInMillis(); return l; } catch (ParseException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
/** * templete: FORMAT_STR -> Date/* w w w . j a v a2 s .co m*/ * * @param str * @param format * @return */ public static Date str2date(String str, String format) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); Date date = null; try { date = simpleDateFormat.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static long getLongFromDate(String date) { SimpleDateFormat sdf = new SimpleDateFormat("E,dd MMM yyyy", Locale.US); long time = 0; try {// w w w .jav a2 s . c o m time = sdf.parse(date).getTime(); } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static long getLongForPresentDate(String date) { SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy", Locale.US); long time = 0; try {/*from w w w . j ava2 s . c o m*/ time = sdf.parse(date).getTime(); } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getTimes(String times) { String time = ""; try {/*from www . j a va 2 s . co m*/ Date epoch = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(times.toString().substring(8, 10) + "/" + times.toString().substring(5, 7) + "/" + times.toString().substring(0, 4) + " 01:00:00"); time = epoch.getTime() / 1000 + ""; } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static int getMonth(String sDate) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date d = null;/* w w w . ja v a2s. co m*/ try { d = df.parse(sDate); } catch (ParseException e) { e.printStackTrace(); } if (d == null) { return 0; } return d.getMonth(); }