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

java.util.DateparseDate(String sDate)
parse Date
java.text.DateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date retDate = null;
try {
    retDate = formatter.parse(sDate);
} catch (Exception ex) {
return retDate;
DateparseDate(String sDate)
parse Date
SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
    Date date = bartDateFormat.parse(sDate);
    return date;
} catch (Exception ex) {
return null;
java.util.DateparseDate(String sDate)
Parse the given date ( supposed to be in ISO format : "YYYY-MM-DD" )
if (sDate == null)
    return null;
if (sDate.length() == 0)
    return null;
char c = 0;
for (int i = 0; i < 10; i++) 
    c = sDate.charAt(i);
...
DateparseDate(String sDate, Locale locale)
parse Date
Date date = parseW3CDateTime(sDate, locale);
if (date == null) {
    date = parseRFC822(sDate, locale);
    if ((date == null) && (ADDITIONAL_MASKS.length > 0)) {
        date = parseUsingMask(ADDITIONAL_MASKS, sDate, locale);
return date;
...
java.util.DateparseDate(String sDate, SimpleDateFormat _dateFormat)
parse Date
sDate = (sDate != null) ? sDate.trim() : null;
if (sDate == null || sDate.length() == 0)
    return null;
ParsePosition pp;
java.util.Date d = null;
try {
    pp = new ParsePosition(0);
    d = _dateFormat.parse(sDate, pp);
...
java.util.DateparseDate(String sDate, String sFormat)
parse Date
java.text.SimpleDateFormat formatter = null;
java.util.Date utildate = null;
formatter = new java.text.SimpleDateFormat(sFormat);
utildate = formatter.parse(sDate);
return utildate;
StringparseDate(String sDate, String sSourceFormat, String sDestinationFormat)
parse Date
String sRtn = "";
try {
    sRtn = new java.text.SimpleDateFormat(sDestinationFormat)
            .format(new java.text.SimpleDateFormat(sSourceFormat).parse(sDate));
} catch (Exception ex) {
    ex.printStackTrace();
return sRtn;
...
DateparseDate(String sdate, String timeFormat, String timeZone)
parse Date
SimpleDateFormat sdf = getDateFormatter(timeFormat);
TimeZone ltz = TimeZone.getDefault();
Date date;
try {
    date = sdf.parse(sdate);
} catch (ParseException pe) {
    throw new RuntimeException("Cannot parse date: " + sdate + "; " + pe.getMessage(), pe);
Date nd = date;
TimeZone tz = TimeZone.getTimeZone(timeZone);
if (ltz.hasSameRules(tz) == false) {
    long lo = ltz.getRawOffset();
    long to = tz.getRawOffset();
    nd = new Date(date.getTime() - to + lo);
return nd;
DateparseDate(String sDateTime, String sPattern)
Parse the String to return a valid Date object.
TimeZone timeZone = TimeZone.getDefault();
Date date = parseDate(sDateTime, sPattern, timeZone);
return date;
DateparseDate(String source, String format)
parse Date
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
    return sdf.parse(source);
} catch (ParseException e) {
    return null;