Here you can find the source of parseRFC822Date(String value)
public static Date parseRFC822Date(String value)
//package com.java2s; /******************************************************************************* * Copyright 2012 Jack Wang/*from w w w . j a v a 2 s . c o m*/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat rfc822DateFormats[] = new SimpleDateFormat[] { new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z"), new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"), new SimpleDateFormat("EEE, d MMM yy HH:mm:ss z"), new SimpleDateFormat("EEE, d MMM yyyy HH:mm z"), new SimpleDateFormat("EEE, d MMM yy HH:mm z"), new SimpleDateFormat("d MMM yyyy HH:mm:ss z"), new SimpleDateFormat("d MMM yy HH:mm:ss z"), new SimpleDateFormat("d MMM yyyy HH:mm z"), new SimpleDateFormat("d MMM yy HH:mm z"), new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss"), // without timezone new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss"), new SimpleDateFormat("EEE, d MMM yy HH:mm:ss"), new SimpleDateFormat("EEE, d MMM yyyy HH:mm"), new SimpleDateFormat("EEE, d MMM yy HH:mm"), new SimpleDateFormat("d MMM yyyy HH:mm:ss"), new SimpleDateFormat("d MMM yy HH:mm:ss"), new SimpleDateFormat("d MMM yyyy HH:mm"), new SimpleDateFormat("d MMM yy HH:mm"), new SimpleDateFormat("EEE, d MMM yy HH:mm:ssz") // newegg.com Thu, 3 Sep 2009 11:23:10GMT }; public static Date parseRFC822Date(String value) { for (SimpleDateFormat formatter : rfc822DateFormats) { try { Date date = formatter.parse(value); return date; } catch (ParseException e) { continue; } } // progressively trim the space and retry till end of it int i = value.lastIndexOf(" "); if (i > 6) { value = value.substring(0, i); return parseRFC822Date(value); } return null; } }