Here you can find the source of parseExpireField(String timestring)
public static Date parseExpireField(String timestring)
//package com.java2s; /*/*ww w . j a v a2s .c om*/ * Copyright (c) 2010-2012 Sonatype, Inc. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. * * Unless required by applicable law or agreed to in writing, * software distributed under the Apache License Version 2.0 is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. */ import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public final static ThreadLocal<SimpleDateFormat[]> SIMPLE_DATE_FORMATS = new ThreadLocal<SimpleDateFormat[]>() { protected SimpleDateFormat[] initialValue() { return new SimpleDateFormat[] { new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), // RFC1123 new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), // RFC1036 new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US), // ASCTIME new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US), new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss z", Locale.US), new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US), new SimpleDateFormat("EEE, dd-MMM-yyyy HH:mm:ss Z", Locale.US) }; } }; public static Date parseExpireField(String timestring) { SimpleDateFormat[] sdfs = SIMPLE_DATE_FORMATS.get(); for (SimpleDateFormat sdf : sdfs) { Date date = sdf.parse(timestring, new ParsePosition(0)); if (date != null) return date; } return null; } }