List of utility methods to do Parse Date
Date | parseDate4UrlCreateTime(String dateStr) parse Date Url Create Time Date result = null; try { result = new SimpleDateFormat(FMT_4_URL_CREATETIME).parse(dateStr); } catch (ParseException e) { e.printStackTrace(); return result; |
Date | parseDateAllowNull(String date) parse Date Allow Null DateFormat df = new SimpleDateFormat("dd/MMM/yyyy"); return (date == null || date.isEmpty()) ? null : df.parse(date); |
String | parseDateAndGetLong(String date) parse Date And Get Long DateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT); try { return String.valueOf(format.parse(date).getTime()); } catch (ParseException e) { e.printStackTrace(); return ""; |
String | parseDateAsString(Date value) parse Date As String return parseAsString(BR_DATE_PATTERN, value);
|
Date | parseDateForFilter(String date) parse Date For Filter if (date != null) { try { return filterDatesFormatter.parse(date); } catch (ParseException e) { return null; |
Calendar | parseDateFormat(String s, String pattern, TimeZone tz) Parses a string using SimpleDateFormat and a given pattern. assert (pattern != null); ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, pattern, tz, pp); if (pp.getIndex() != s.length()) { return null; return ret; |
Date | parseDateFrom(String dateStr) parse Date From if (null == dateStr) { return new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date value = null; try { value = sdf.parse(dateStr); } catch (ParseException ex) { ... |
Date | parseDateFromDateStr(String date) Parse date from the string in "yyyy-MM-dd" format. SimpleDateFormat s = getDateFormat(DATE_FORMAT);
return s.parse(date);
|
Date | parseDateFromDateTimeStr(String date) parse Date From Date Time Str SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return s.parse(date); |
Date | parseDateFromDefault(String dateString) Parse a string in standard input format, in the default time zone, into a Date. if ((dateString == null) || (dateString.trim().length() == 0)) return null; DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, Locale.getDefault()); format.setTimeZone(TimeZone.getDefault()); Date rv = format.parse(dateString); return rv; |