HttpDate.java
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.squareup.okhttp.internal.http;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public final class HttpDate
{
private static final DateFormat[] BROWSER_COMPATIBLE_DATE_FORMATS = new DateFormat[15];
private static final String[] BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS;
private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final ThreadLocal<DateFormat> STANDARD_DATE_FORMAT = new ThreadLocal()
{
protected final DateFormat initialValue()
{
SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
localSimpleDateFormat.setLenient(false);
localSimpleDateFormat.setTimeZone(HttpDate.GMT);
return localSimpleDateFormat;
}
};
static
{
BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS = new String[] { "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" };
}
public static String format(Date paramDate)
{
return ((DateFormat)STANDARD_DATE_FORMAT.get()).format(paramDate);
}
public static Date parse(String paramString)
{
int i = 0;
Object localObject;
if (paramString.length() == 0) {
localObject = null;
}
ParsePosition localParsePosition;
do
{
return (Date)localObject;
localParsePosition = new ParsePosition(0);
localObject = ((DateFormat)STANDARD_DATE_FORMAT.get()).parse(paramString, localParsePosition);
} while (localParsePosition.getIndex() == paramString.length());
for (;;)
{
synchronized (BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS)
{
int j = BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS.length;
if (i >= j) {
break;
}
DateFormat localDateFormat = BROWSER_COMPATIBLE_DATE_FORMATS[i];
localObject = localDateFormat;
if (localDateFormat == null)
{
localObject = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US);
((DateFormat)localObject).setTimeZone(GMT);
BROWSER_COMPATIBLE_DATE_FORMATS[i] = localObject;
}
localParsePosition.setIndex(0);
localObject = ((DateFormat)localObject).parse(paramString, localParsePosition);
if (localParsePosition.getIndex() != 0) {
return (Date)localObject;
}
}
i += 1;
}
return null;
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/okhttp/internal/http/HttpDate.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/