what-the-bank/sources/okhttp3/internal/http/DatesKt.java

68 lines
3.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package okhttp3.internal.http;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import o.C14866gag;
import o.C14957gcv;
import okhttp3.internal.Util;
/* loaded from: classes.dex */
public final class DatesKt {
public static final long MAX_DATE = 253402300799999L;
private static final DatesKt$STANDARD_DATE_FORMAT$1 STANDARD_DATE_FORMAT = new ThreadLocal<DateFormat>() { // from class: okhttp3.internal.http.DatesKt$STANDARD_DATE_FORMAT$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[] BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS = {"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[] BROWSER_COMPATIBLE_DATE_FORMATS = new DateFormat[15];
public static final Date toHttpDateOrNull(String str) {
C14957gcv.e(str, "");
if (str.length() == 0) {
return null;
}
ParsePosition parsePosition = new ParsePosition(0);
Date parse = STANDARD_DATE_FORMAT.get().parse(str, parsePosition);
if (parsePosition.getIndex() == str.length()) {
return parse;
}
String[] strArr = BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS;
synchronized (strArr) {
int length = strArr.length;
for (int i = 0; i < length; i++) {
DateFormat[] dateFormatArr = BROWSER_COMPATIBLE_DATE_FORMATS;
SimpleDateFormat simpleDateFormat = dateFormatArr[i];
if (simpleDateFormat == null) {
SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US);
simpleDateFormat2.setTimeZone(Util.UTC);
simpleDateFormat = simpleDateFormat2;
dateFormatArr[i] = simpleDateFormat;
}
parsePosition.setIndex(0);
Date parse2 = simpleDateFormat.parse(str, parsePosition);
if (parsePosition.getIndex() != 0) {
return parse2;
}
}
C14866gag c14866gag = C14866gag.c;
return null;
}
}
public static final String toHttpDateString(Date date) {
C14957gcv.e(date, "");
String format = STANDARD_DATE_FORMAT.get().format(date);
C14957gcv.c((Object) format, "");
return format;
}
}