what-the-bank/sources/okhttp3/repackaged/internal/http/HttpDate.java

63 lines
2.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.repackaged.internal.http;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import okhttp3.repackaged.internal.Util;
/* loaded from: classes6.dex */
public final class HttpDate {
public static final long MAX_DATE = 253402300799999L;
private static final ThreadLocal<DateFormat> amb = new ThreadLocal<DateFormat>() { // from class: okhttp3.repackaged.internal.http.HttpDate.1
/* JADX INFO: Access modifiers changed from: protected */
@Override // java.lang.ThreadLocal
public final DateFormat initialValue() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
simpleDateFormat.setLenient(false);
simpleDateFormat.setTimeZone(Util.UTC);
return simpleDateFormat;
}
};
private static final String[] amc = {"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"};
private static final DateFormat[] amd = new DateFormat[15];
public static Date parse(String str) {
if (str.length() == 0) {
return null;
}
ParsePosition parsePosition = new ParsePosition(0);
Date parse = amb.get().parse(str, parsePosition);
if (parsePosition.getIndex() == str.length()) {
return parse;
}
String[] strArr = amc;
synchronized (strArr) {
int length = strArr.length;
for (int i = 0; i < length; i++) {
DateFormat[] dateFormatArr = amd;
DateFormat dateFormat = dateFormatArr[i];
if (dateFormat == null) {
dateFormat = new SimpleDateFormat(amc[i], Locale.US);
dateFormat.setTimeZone(Util.UTC);
dateFormatArr[i] = dateFormat;
}
parsePosition.setIndex(0);
Date parse2 = dateFormat.parse(str, parsePosition);
if (parsePosition.getIndex() != 0) {
return parse2;
}
}
return null;
}
}
public static String format(Date date) {
return amb.get().format(date);
}
private HttpDate() {
}
}