List of utility methods to do Parse Date
Date | parseDateTimeString(String dateTimeString) parse Date Time String DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); try { Date d = (Date) formatter.parse(dateTimeString); return d; } catch (ParseException e) { return null; |
String[] | parseDateToStr(Date date) Parse Date to array of string String strFormat = "ddMMyyyy"; SimpleDateFormat dateFormat = new SimpleDateFormat(strFormat); String[] arrDate = new String[3]; String strDate = null; if (date == null) return arrDate; strDate = dateFormat.format(date); arrDate[0] = strDate.substring(0, 2); ... |
String | parseDateToString(Date date, String format) This is method parse format date to string Version: OEP 1.1 History: DATE AUTHOR DESCRIPTION ------------------------------------------------- 26-March-2015 ThongDV Create new try { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } catch (Exception e) { return ""; |
String | parseDateToString(Date date, String pattern) Parses the Date in given format and returns the string representation. String d = ""; if (date != null) { SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); d = dateFormat.format(date); return d; |
String | parseDateToString(Date datetime) parse Date To String SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Date sDate = new java.util.Date(datetime.getTime()); return df.format(sDate); |
String | parseDateToString(final Date date, final String dateFormat, final String lang) Parses a date to a particular format and returns the formatted String . Preconditions.checkNotNull(date); Preconditions.checkNotNull(dateFormat); Preconditions.checkNotNull(lang); final Locale locale = new Locale(lang); final SimpleDateFormat format = new SimpleDateFormat(dateFormat, locale); return format.format(date); |
Date | parseDateValue(String value) parse Date Value try { return getTimeFormat().parse(value); } catch (ParseException e) { throw new IllegalArgumentException("Expected date field of format '" + ISO_8601_DATE_FORMAT + "', but found value '" + value + "'.", e); |
Date | parseDateWithFormat(String date, SimpleDateFormat dateFormat, Date defaultDate) parse Date With Format try { return dateFormat.parse(date); } catch (ParseException e) { e.printStackTrace(); return defaultDate; |
Date | parseDateWithLeniency(final String str, final Locale locale, final String[] parsePatterns, final boolean lenient) Parses a string representing a date by trying a variety of different parsers. if (str == null || parsePatterns == null) { throw new IllegalArgumentException("Date and Patterns must not be null"); SimpleDateFormat parser; if (locale == null) { parser = new SimpleDateFormat(); } else { parser = new SimpleDateFormat("", locale); ... |
Date | parseDateWithoutTime(final String date) parse Date Without Time return parseDateWithoutTime(date, false);
|