List of utility methods to do Parse Date
Date | parseDate(String date, String format) Parses a datetime+timezone string in the given format, returning a UTC date. return parseDate(date, format, null);
|
Date | parseDate(String date, String format) parse Date DateFormat df = new SimpleDateFormat(format); try { return df.parse(date); } catch (ParseException e) { throw new IllegalArgumentException( String.format("Could not parse date %s with format %s", date, format)); |
Date | parseDate(String date, String format) parse Date SimpleDateFormat df = new SimpleDateFormat(format); return df.parse(date); |
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); ... |
Date | parseDate(String date, String pattern) parse Date SimpleDateFormat df = new SimpleDateFormat(pattern); df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); try { return df.parse(date); } catch (ParseException e) { throw new IllegalArgumentException(e); |
Date | parseDate(String date, String pattern) parse Date if ((date == null) || (pattern == null)) { throw new IllegalArgumentException(); try { return new SimpleDateFormat(pattern).parse(date); } catch (Exception e) { return null; |
Date | parseDate(String date, String pattern) Methods Descrip: Date returnDate = null; if (pattern == null || pattern.equals("") || pattern.equals("null")) { pattern = "yyyy-MM-dd"; java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(pattern); try { returnDate = sdf.parse(date); } catch (Exception e) { ... |
Date | parseDate(String date, String pattern, TimeZone zone) Parses a date using a pattern describing the date and time format. DateFormat dfmt = new SimpleDateFormat(pattern); dfmt.setTimeZone(zone); return dfmt.parse(date); |
Date | parseDate(String dateAsString) parse Date return parseDate(dateAsString, DEFAULT_DATE_FORMAT);
|
Date | parseDate(String dateAsString) Parses the date. Date date = null; Pattern datePattern = Pattern.compile("([0-9]{2})[_\\.-]([0-9]{2})[_\\.-]([0-9]{4})"); Matcher m = datePattern.matcher(dateAsString); if (m.find()) { date = new SimpleDateFormat("dd-MM-yyyy").parse(m.group(1) + "-" + m.group(2) + "-" + m.group(3)); } else { datePattern = Pattern.compile("([0-9]{4})[_\\.-]([0-9]{2})[_\\.-]([0-9]{2})"); m = datePattern.matcher(dateAsString); ... |