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

DateparseDateFromHeader(String datestr)
Parses the string in a format suitable for a SMTP date header.
synchronized (DATE_HEADER_FORMAT_INT) {
    return DATE_HEADER_FORMAT_INT.parse(datestr);
ObjectparseDateFromString(String valor, String formatoFecha)
parse Date From String
try {
    SimpleDateFormat dateFormat = new SimpleDateFormat(formatoFecha);
    if (valor.trim().length() != dateFormat.toPattern().length())
        throw new IllegalArgumentException("No tiene un formato de fecha correcto : " + formatoFecha);
    dateFormat.setLenient(Boolean.FALSE);
    return dateFormat.parse(valor.trim());
} catch (ParseException pe) {
    throw new IllegalArgumentException("No tiene un formato de fecha correcto o la fecha no existe: ("
...
longparseDateHeader(String header)
parse Date Header
if (header != null && header.length() > 0) {
    for (DateFormat rfc822Format : RFC822_PARSE_PATTERNS) {
        try {
            Date headerDate = rfc822Format.parse(header);
            return headerDate.getTime();
        } catch (NumberFormatException e) {
            continue;
        } catch (ParseException e) {
...
LongparseDateHeader(String value)
parse Date Header
Date date = null;
for (int i = 0; (date == null) && (i < HTTP_REQUEST_DATE_HEADER.length); i++) {
    try {
        SimpleDateFormat format = new SimpleDateFormat(HTTP_REQUEST_DATE_HEADER[i], Locale.US);
        format.setTimeZone(GMT);
        date = format.parse(value);
    } catch (ParseException e) {
if (date == null) {
    return null;
return Long.valueOf(date.getTime());
StringparseDateHHmm(java.util.Date date)
parse Date H Hmm
return new SimpleDateFormat(DATE_FORMAT_HH_mm).format(date);
DateparseDateHHMM(String hhmm)
parse Date HHMM
return simpleHHmmTimeFormat.parse(hhmm);
DateparseDateHMSMZ(String dateString)
Transform the XML Schema format for the timezone to Java format.
if (dateString == null || dateString.length() < 12)
    throw new IllegalArgumentException("Invalid date string " + dateString);
if (dateString.length() == 12) 
    dateString += "-0000";
else if (dateString.length() == 13 && dateString.endsWith("Z"))
    dateString = dateString.substring(0, 12) + "-0000";
else if (dateString.length() == 18) {
    String tz = dateString.substring(13);
...
ListparseDateList(List dateList)
Returns a List of parsed date strings.
List<Date> newList = new ArrayList<Date>();
if (dateList == null)
    return newList;
for (String value : dateList)
    newList.add(parseDate(value));
return newList;
DateparseDateLong(String date, Locale locale)
Parses the specified date in the DateFormat#LONG format and locale and returns the Date instance using the system default time zone.
return DateFormat.getDateInstance(DateFormat.LONG, locale).parse(date);
DateparseDateLongFormat(String sDate)
parse Date Long Format
DateFormat dateFormat = new SimpleDateFormat(longFormat);
Date d = null;
if ((sDate != null) && (sDate.length() == longFormat.length())) {
    try {
        d = dateFormat.parse(sDate);
    } catch (ParseException ex) {
        return null;
return d;