List of utility methods to do Date String Parse
Date | parseDateStrictly(String str, String... parsePatterns) Parses a string representing a date by trying a variety of different parsers. The parse will try each parse pattern in turn. return parseDateWithLeniency(str, parsePatterns, false);
|
Date | parseDateTime(String dateString) parse Date Time, "E MMM d HH:mm:ss Z yyyy" try { Log.v(TAG, String.format("in parseDateTime, dateString=%s", dateString)); return TWITTER_DATE_FORMATTER.parse(dateString); } catch (ParseException e) { Log.w(TAG, "Could not parse Twitter date string: " + dateString); return null; |
Date | parseDateWithLeniency(String str, String[] parsePatterns, boolean lenient) Parses a string representing a date by trying a variety of different parsers. The parse will try each parse pattern in turn. if (str == null || parsePatterns == null) { throw new IllegalArgumentException( "Date and Patterns must not be null"); SimpleDateFormat parser = new SimpleDateFormat(); parser.setLenient(lenient); ParsePosition pos = new ParsePosition(0); for (String parsePattern : parsePatterns) { ... |
Date | parseLongFormat(String dateString) parse Long Format return parse(dateString, LOCAL_LONG_DATE_FORMAT);
|
Date | parseSearchApiDateTime(String dateString) parse Search Api Date Time, "E, d MMM yyyy HH:mm:ss Z" try { return TWITTER_SEARCH_API_DATE_FORMATTER.parse(dateString); } catch (ParseException e) { Log.w(TAG, "Could not parse Twitter search date string: " + dateString); return null; |
Calendar | parseString(String dateStr) parse String return parseString(dateStr, DEFAULTFORMAT);
|
Calendar | parseString(String dateStr, String pattern) parse String SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date date = sdf.parse(dateStr); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; |
Date | parseStringToDate(String str) parse String To Date return parseDate(str, "yyyyMMddHHmm"); |
Date | parseTM(String s, boolean end) Parses a value that has a TM VR as a Date . if (s == null || s.length() == 0) { return null; Calendar c = new GregorianCalendar(); c.clear(); if (end) { setTo2359(c); parseTM(c, s, 0, s.length()); return c.getTime(); |
Date | parseDate(String date) parse Date try { SimpleDateFormat dateFormat = new SimpleDateFormat( DEFAULT_DATE_FORMAT); return dateFormat.parse(date); } catch (ParseException e) { e.printStackTrace(); return new Date(); ... |