Java Parse RFC Date parseRFC822(String str)

Here you can find the source of parseRFC822(String str)

Description

parse RFC

License

Open Source License

Declaration

public static Date parseRFC822(String str) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    private static final SimpleDateFormat rfc822DateFormats[] = new SimpleDateFormat[] {
            new SimpleDateFormat("EEE, d MMM yy HH:mm:ss z"), new SimpleDateFormat("EEE, d MMM yy HH:mm z"),
            new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z"), new SimpleDateFormat("EEE, d MMM yyyy HH:mm z"),
            new SimpleDateFormat("d MMM yy HH:mm z"), new SimpleDateFormat("d MMM yy HH:mm:ss z"),
            new SimpleDateFormat("d MMM yyyy HH:mm z"), new SimpleDateFormat("d MMM yyyy HH:mm:ss z"), };

    public static Date parseRFC822(String str) {
        for (SimpleDateFormat rfc822DateFormat : rfc822DateFormats) {
            try {
                Date theDate = rfc822DateFormat.parse(str);
                if (theDate instanceof Date)
                    return theDate;
            } catch (ParseException e) {

            }//www . j  a v a2  s  .  c om
        }

        return null;
    }
}

Related

  1. parseRfc3339Date(String date)
  2. parseRFC3339Date(String datestring)
  3. parseRFC3339Date(String datestring)
  4. parseRFC822(String dateString)
  5. parseRFC822(String sDate, Locale locale)
  6. parseRfc822Date(String dateString)
  7. parseRfc822Date(String dt)
  8. parseRFC822Date(String value)
  9. parseRfc822DateTime(String datestr)