List of utility methods to do Parse Date
Date | parseDate(String date) parse Date if (date.endsWith("Z")) { date = date.substring(0, date.length() - 1); if (date.length() == 10) { date = date + "T00:00:00"; date = date.replaceAll("^(\\d{4})(\\d{2})(\\d{2})T(\\d{2})(\\d{2})(\\d{2})$", "$1-$2-$3T$4:$5:$6"); date = date.replaceAll("^(\\d{4})(\\d{2})(\\d{2})$", "$1-$2-$3T00:00:00"); ... |
String | parseDate(String date) Takes a stringified date, and returns it in xsd:date format. StringBuilder outDate = new StringBuilder(); if (date != null) { DateFormat df = DateFormat.getDateInstance(); df.setLenient(true); Calendar c = Calendar.getInstance(); try { c.setTime(df.parse(date)); outDate.append(c.get(Calendar.YEAR)); ... |
Date | parseDate(String date) parse Date for (SimpleDateFormat pattern : knownPatterns) { try { return new Date(pattern.parse(date).getTime()); } catch (ParseException pe) { return null; |
ArrayList | parseDate(String date) parse Date date = date.trim(); ArrayList<Long> pdates = new ArrayList<Long>(); if (dateFormats == null) { dateFormats = new ArrayList<SimpleDateFormat>(); dateFormats.add(new SimpleDateFormat("yyyy-MM-dd")); dateFormats.add(new SimpleDateFormat("yyyy MM dd")); dateFormats.add(new SimpleDateFormat("yyyy.MM.dd")); dateFormats.add(new SimpleDateFormat("yyyy-MMM-dd")); ... |
Date | parseDate(String date) parse Date SimpleDateFormat format = new SimpleDateFormat(common_pattern); try { return format.parse(date); } catch (Exception e) { e.printStackTrace(); return null; |
Date | parseDate(String date) parse Date return getDateFormat().parse(date);
|
Date | parseDate(String date) parse Date return parseDate(date, ""); |
String | parseDate(String date, Locale locale) parse Date SimpleDateFormat formatter = new SimpleDateFormat("EE, dd.MM.yyyy", locale); SimpleDateFormat destinationFormat = new SimpleDateFormat("dd.MM.yyyy", locale); formatter.setLenient(true); try { Date fDate = formatter.parse(date); String ret = destinationFormat.format(fDate); return ret; } catch (ParseException e) { ... |
Date | parseDate(String date, String expression) parse Date try { if (isEmpty(expression)) { expression = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(expression); return sdf.parse(date); } catch (Exception e) { return null; ... |
Date | parseDate(String date, String format) parse Date if (date == null) { return null; date = date.trim(); if (date.length() == 0) { return null; SimpleDateFormat dateFormat = new SimpleDateFormat(format); ... |