Java Date RFC Format resolvedDateRFC822(String pString)

Here you can find the source of resolvedDateRFC822(String pString)

Description

resolved Date RFC

License

LGPL

Declaration

public static Date resolvedDateRFC822(String pString) throws ParseException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.text.*;
import java.util.Date;

public class Main {
    static DateFormat formatter;

    public static Date resolvedDateRFC822(String pString) throws ParseException {
        Date lDate = null;/*from   w  ww  .j av a  2 s .c om*/
        String[] lDateFormats = { "EEE, dd MMM yyyy kk:mm:ss z", "EEE, MMM dd yyyy kk:mm:ss z" };

        if (pString != null && !"".equals(pString)) {
            SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
            for (int i = 0; i < lDateFormats.length; i++) {
                String lFormat = lDateFormats[i];
                simpleFormatter.applyPattern(lFormat);
                try {
                    lDate = simpleFormatter.parse(pString);
                    break;
                } catch (ParseException pe) {
                    // keep trying.
                }
            }
            if (lDate == null) {
                throw new ParseException("Not RFC 822 parsebale date format", 0);
            }
        } else {
            throw new IllegalArgumentException();
        }
        return lDate;
    }
}

Related

  1. getRfc822DateFormat()
  2. getRfc822DateStringGMT(Date date)
  3. getRFC822String(Date date)
  4. makeDateRFC2822(Date date)
  5. renderDateAsRFC822String(Date date)
  6. rfc1123Date(Date d)
  7. rfc1123Format(Date date)
  8. rfc2822(Date date)
  9. rfc822(Date date)