List of utility methods to do Date String Parse
Date | parse(String dateStr) Converts the given string into a java.util.Date object using the defined default format yyyy-MM-dd HH:mm Date parsedDate; try { parsedDate = DEFAULT_FORMATTER.parse(dateStr); } catch (ParseException e) { Log.e(PictureDownloader.TAG, "Error parsing date string: " + dateStr + " - returning current date..."); parsedDate = new Date(); return parsedDate; |
Date | parse(String input) parse return new SimpleDateFormat("yyyyMMddHHmmss").parse(input); |
Date | parse(String source, String pattern) parse if (source == null) { return null; Date date; try { date = getFormat(pattern).parse(source); } catch (ParseException e) { return null; ... |
Date | parseDate(String value, String[] parsePatterns) parse Date if (value == null || parsePatterns == null) { throw new IllegalArgumentException( "Date and Patterns must not be null"); SimpleDateFormat parser = null; ParsePosition pos = new ParsePosition(0); for (int i = 0; i < parsePatterns.length; i++) { if (i == 0) { ... |
Date | parseJsonDate(String jsonDate) parse Json Date Date d = null; if (jsonDate != null) { d = parseDate(jsonDate, FORMAT_4); if (d == null) { d = parseDate(jsonDate); return d; ... |
java.sql.Date | str2Date(String str) str Date if (str == null) return null; str = str.trim(); if (!str.matches("^\\d\\d\\d\\d-\\d\\d-\\d\\d$") && !str.matches("^\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d$")) return null; String[] ss = str.split("-| |:"); GregorianCalendar gc = new GregorianCalendar(); ... |
Date | stringConvertDate(String date) string Convert Date if (null == date || "".equals(date)) { return null; if (date.length() == 10) { date = date + " 00:00:00"; } else if (date.length() == 16) { date = date + ":00"; SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); Date objDate; try { objDate = formatter.parse(date); } catch (ParseException e) { objDate = null; return objDate; |
Date | stringToDate(String date) string To Date formatter.setTimeZone(TimeZone.getTimeZone("gmt")); return (formatter.parse(date)); |
Date | toDate(String string) to Date return new Date(); |
int[] | tokenizeDate(String date) tokenize Date StringTokenizer st = new StringTokenizer(date, "-/"); ArrayList<Integer> al = new ArrayList<Integer>(); while (st.hasMoreTokens()) { al.add(Integer.parseInt(st.nextToken())); int[] tokenList = new int[3]; for (int i = 0; i < al.size(); i++) { tokenList[i] = al.get(i); ... |