Java Utililty Methods Date Parse

List of utility methods to do Date Parse

Description

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

Method

DategetDateFromISO8601(String iso8601Date)
get Date From ISO
SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_DATE_FORMAT);
try {
    return sdf.parse(iso8601Date);
} catch (ParseException e) {
    e.printStackTrace();
    return null;
DategetDateFromIsoString(String dateString)
Parse ISO 8601 date string into Date object.
return getDateFromString(dateString, ISO8601);
DategetDateFromISOString(String iso)
get Date From ISO String
SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_FORMAT);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
sdf.setLenient(false);
try {
    if (iso == null)
        return null;
    return sdf.parse(iso);
} catch (ParseException e) {
...
StringgetDateFromOffset(Date prevDate, int offset)
get Date From Offset
Date dt = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
Calendar c = Calendar.getInstance();
c.setTime(prevDate);
c.add(Calendar.DATE, offset);
return dateFormat.format(c.getTime());
DategetDateFromOriDateStr(String strDate)
get Date From Ori Date Str
Date date = null;
if (null == strDate || "".equals(strDate)) {
    return null;
} else {
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
    try {
        date = sdf.parse(strDate);
    } catch (ParseException e1) {
...
StringgetDateFromRange(String date)
get Date From Range
java.util.Calendar calendar = java.util.Calendar.getInstance();
calendar.setTime(getDateFromStr(date));
return formatterDDMMYYYYEx.format(calendar.getTime());
DategetDateFromRequestStringDate(String dateString)
get Date From Request String Date
Date resDate = null;
try {
    String dateSource = dateString;
    dateSource = dateSource.trim();
    dateSource = dateSource.replaceAll("T", " ");
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    resDate = simpleDateFormat.parse(dateSource);
} catch (ParseException exc) {
...
DategetDateFromRFC822String(Object rfc822)
FIX: In order to make EPL nested calls, we need this guy to be able to accept Object which is a string actually
return rfc822 == null ? null
        : new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy").parse(rfc822.toString());
DategetDateFromStr(DateFormat format, String s)
get Date From Str
if (s == null || s.trim().equals("")) {
    return null;
if (format == null) {
    if (s.length() == 10) {
        format = format_yyyyMMdd;
    } else if (s.length() == 16) {
        format = format13;
...
DategetDateFromStr(String date)
get Date From Str
Date result = null;
try {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    sdf.setLenient(false);
    result = sdf.parse(date);
} catch (Exception e) {
    System.out.println("Error: " + e.toString());
return result;