package XnFJ5_9.Ft6VRog_36.Xgtqvk_8;

import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/* compiled from: HttpDate.java */
/* loaded from: classes.dex */
public final class Mqv2r_3 {
    public static final ThreadLocal<DateFormat> KQgRr5e_0 = new KQgRr5e_0();

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final String[] f1625KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public static final DateFormat[] f1626KQgRr5e_0;

    /* compiled from: HttpDate.java */
    /* loaded from: classes.dex */
    public class KQgRr5e_0 extends ThreadLocal<DateFormat> {
        @Override // java.lang.ThreadLocal
        /* renamed from: KQgRr5e_0 */
        public DateFormat initialValue() {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
            simpleDateFormat.setLenient(false);
            simpleDateFormat.setTimeZone(XnFJ5_9.Ft6VRog_36.X6FRs_4.f1615KQgRr5e_0);
            return simpleDateFormat;
        }
    }

    static {
        String[] strArr = {"EEE, dd MMM yyyy HH:mm:ss zzz", "EEEE, dd-MMM-yy HH:mm:ss zzz", "EEE MMM d HH:mm:ss yyyy", "EEE, dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MMM-yyyy HH-mm-ss z", "EEE, dd MMM yy HH:mm:ss z", "EEE dd-MMM-yyyy HH:mm:ss z", "EEE dd MMM yyyy HH:mm:ss z", "EEE dd-MMM-yyyy HH-mm-ss z", "EEE dd-MMM-yy HH:mm:ss z", "EEE dd MMM yy HH:mm:ss z", "EEE,dd-MMM-yy HH:mm:ss z", "EEE,dd-MMM-yyyy HH:mm:ss z", "EEE, dd-MM-yyyy HH:mm:ss z", "EEE MMM d yyyy HH:mm:ss z"};
        f1625KQgRr5e_0 = strArr;
        f1626KQgRr5e_0 = new DateFormat[strArr.length];
    }

    public static Date KQgRr5e_0(String str) {
        if (str.length() == 0) {
            return null;
        }
        ParsePosition parsePosition = new ParsePosition(0);
        Date parse = KQgRr5e_0.get().parse(str, parsePosition);
        if (parsePosition.getIndex() == str.length()) {
            return parse;
        }
        synchronized (f1625KQgRr5e_0) {
            int length = f1625KQgRr5e_0.length;
            for (int i = 0; i < length; i++) {
                DateFormat dateFormat = f1626KQgRr5e_0[i];
                if (dateFormat == null) {
                    dateFormat = new SimpleDateFormat(f1625KQgRr5e_0[i], Locale.US);
                    dateFormat.setTimeZone(XnFJ5_9.Ft6VRog_36.X6FRs_4.f1615KQgRr5e_0);
                    f1626KQgRr5e_0[i] = dateFormat;
                }
                parsePosition.setIndex(0);
                Date parse2 = dateFormat.parse(str, parsePosition);
                if (parsePosition.getIndex() != 0) {
                    return parse2;
                }
            }
            return null;
        }
    }

    public static String KQgRr5e_0(Date date) {
        return KQgRr5e_0.get().format(date);
    }
}
