List of utility methods to do Parse Date
Date | parseDate(String dateStr) parse Date try { if (isValidDateString(dateStr)) { return (new SimpleDateFormat(DATE_FORMAT).parse(dateStr)); } else if (dateStr.indexOf("T") > 0) { return (new SimpleDateFormat(DATE_FORMAT).parse(dateStr.substring(0, dateStr.indexOf('T')))); } else { return (new SimpleDateFormat(DATE_FORMAT).parse(dateStr.substring(0, dateStr.indexOf(" ")))); } catch (ParseException e) { throw new IllegalArgumentException("Invalid date format: " + dateStr, e); |
Date | parseDate(String dateStr) parse Date return parseDate(dateStr, "yyyy-MM-dd"); |
Date | parseDate(String datestr) parse Date if (null == datestr || "".equals(datestr)) { return null; try { String fmtstr = null; if (datestr.contains(":") && datestr.contains("-")) { fmtstr = "yyyy-MM-dd HH:mm:ss"; } else if (datestr.contains(":") && datestr.contains("/")) { ... |
Date | parseDate(String dateStr, SimpleDateFormat... formats) parse Date for (SimpleDateFormat sdf : formats) { try { return sdf.parse(dateStr); } catch (ParseException ignored) { return null; |
Date | parseDate(String dateStr, String dateFormat) Parse the date in string format based on date format and return a Date object DateFormat format = new SimpleDateFormat(dateFormat); return format.parse(dateStr); |
Date | parseDate(String dateStr, String dateFormat) parse Date return new SimpleDateFormat(dateFormat).parse(dateStr); |
Date | parseDate(String dateStr, String format) Parse the date with the given date string and date format. if (isNullOrEmpty(format) || isNullOrEmpty(dateStr)) { return null; SimpleDateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.parse(dateStr.trim()); |
Date | parseDate(String dateStr, String format) parse Date if (dateStr == null) return null; SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition ps = new ParsePosition(0); Date date = formatter.parse(dateStr, ps); return date; |
Date | parseDate(String dateStr, String... formats) Parses a string into Date using the SimpleDateFormat format string provided. return parseDate(dateStr, null, formats);
|
Date | parseDate(String dateString) parse Date return parseDate(dateString, Locale.getDefault(), TimeZone.getDefault());
|