List of utility methods to do Parse Date
Date | parseDateLoose(String dateString) Convenience method for #parseDateStrict(String) which does not throw an exception on error, but merely returns null. try { return parseDateStrict(dateString); } catch (ParseException e) { return null; |
Date | parseDateNewFormat(String sDate) parse Date New Format DateFormat dateFormat = new SimpleDateFormat(newFormat); Date d = dateFormat.parse(sDate); return d; |
Date | parseDateNoTimeWithDelimit(String sDate, String delimit) parse Date No Time With Delimit sDate = sDate.replaceAll(delimit, ""); DateFormat dateFormat = new SimpleDateFormat(shortFormat); if ((sDate == null) || (sDate.length() != shortFormat.length())) { throw new ParseException("length not match", 0); return dateFormat.parse(sDate); |
Calendar | parseDateOrTimeString(String aDateString, String aFormatString) parse Date Or Time String Calendar tempCalendar = Calendar.getInstance();
tempCalendar.setTime(getSimpleDateFormat(aFormatString).parse(aDateString));
return tempCalendar;
|
Date | parseDateRFC(String value) parse Date RFC if (value == null) { return null; try { synchronized (sdf) { sdf.applyPattern(RFC_FORMAT); sdf.setTimeZone(GMT); return sdf.parse(value); ... |
Date | parseDateRfc822(String str) Parse a string in RFC822 GMT format. if (str != null) { try { SimpleDateFormat dateFormater = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); dateFormater.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormater.parse(str); } catch (ParseException ex) { return null; return null; |
Date[] | parseDates(String query) parse Dates String[] segments = SPLIT_PATTERN.split(query); List<Date> dates = new ArrayList<>(); for (String s : segments) { Date date = parse(s.trim()); if (date != null) { dates.add(date); return dates.toArray(new Date[dates.size()]); |
String | parseDateStrFormat(String strDate) parse Date Str Format SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); return sdf.format(strDate); |
Date | parseDateString(String dateStr) parse Date String try { return dateformat.parse(dateStr); } catch (ParseException e) { try { return new Date(dateStr); } catch (Exception e1) { return new Date(); |
Date | parseDateString(String dateString) parse Date String Date d = null; d = parseBingDate(dateString); if (d != null) return d; d = parseBossDate(dateString); if (d != null) return d; d = parseTwitterDate(dateString); ... |