Java Utililty Methods Parse Date

List of utility methods to do Parse Date

Description

The list of methods to do Parse Date are organized into topic(s).

Method

DateparseDate4UrlCreateTime(String dateStr)
parse Date Url Create Time
Date result = null;
try {
    result = new SimpleDateFormat(FMT_4_URL_CREATETIME).parse(dateStr);
} catch (ParseException e) {
    e.printStackTrace();
return result;
DateparseDateAllowNull(String date)
parse Date Allow Null
DateFormat df = new SimpleDateFormat("dd/MMM/yyyy");
return (date == null || date.isEmpty()) ? null : df.parse(date);
StringparseDateAndGetLong(String date)
parse Date And Get Long
DateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT);
try {
    return String.valueOf(format.parse(date).getTime());
} catch (ParseException e) {
    e.printStackTrace();
return "";
StringparseDateAsString(Date value)
parse Date As String
return parseAsString(BR_DATE_PATTERN, value);
DateparseDateForFilter(String date)
parse Date For Filter
if (date != null) {
    try {
        return filterDatesFormatter.parse(date);
    } catch (ParseException e) {
return null;
CalendarparseDateFormat(String s, String pattern, TimeZone tz)
Parses a string using SimpleDateFormat and a given pattern.
assert (pattern != null);
ParsePosition pp = new ParsePosition(0);
Calendar ret = parseDateFormat(s, pattern, tz, pp);
if (pp.getIndex() != s.length()) {
    return null;
return ret;
DateparseDateFrom(String dateStr)
parse Date From
if (null == dateStr) {
    return new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date value = null;
try {
    value = sdf.parse(dateStr);
} catch (ParseException ex) {
...
DateparseDateFromDateStr(String date)
Parse date from the string in "yyyy-MM-dd" format.
SimpleDateFormat s = getDateFormat(DATE_FORMAT);
return s.parse(date);
DateparseDateFromDateTimeStr(String date)
parse Date From Date Time Str
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return s.parse(date);
DateparseDateFromDefault(String dateString)
Parse a string in standard input format, in the default time zone, into a Date.
if ((dateString == null) || (dateString.trim().length() == 0))
    return null;
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT,
        Locale.getDefault());
format.setTimeZone(TimeZone.getDefault());
Date rv = format.parse(dateString);
return rv;