1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.jboss.netty.handler.codec.http2;
24
25 import java.text.ParsePosition;
26 import java.text.SimpleDateFormat;
27 import java.util.Date;
28 import java.util.Locale;
29 import java.util.TimeZone;
30
31
32
33
34
35
36
37
38
39
40
41 final class HttpHeaderDateFormat extends SimpleDateFormat {
42 private static final long serialVersionUID = -925286159755905325L;
43
44 private final SimpleDateFormat format1 = new HttpHeaderDateFormatObsolete1();
45 private final SimpleDateFormat format2 = new HttpHeaderDateFormatObsolete2();
46
47
48
49
50
51 HttpHeaderDateFormat() {
52 super("E, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
53 setTimeZone(TimeZone.getTimeZone("GMT"));
54 }
55
56 @Override
57 public Date parse(String text, ParsePosition pos) {
58 Date date = super.parse(text, pos);
59 if (date == null) {
60 date = format1.parse(text, pos);
61 }
62 if (date == null) {
63 date = format2.parse(text, pos);
64 }
65 return date;
66 }
67
68
69
70
71
72 private static final class HttpHeaderDateFormatObsolete1 extends SimpleDateFormat {
73 private static final long serialVersionUID = -3178072504225114298L;
74
75 HttpHeaderDateFormatObsolete1() {
76 super("E, dd-MMM-y HH:mm:ss z", Locale.ENGLISH);
77 setTimeZone(TimeZone.getTimeZone("GMT"));
78 }
79 }
80
81
82
83
84
85
86 private static final class HttpHeaderDateFormatObsolete2 extends SimpleDateFormat {
87 private static final long serialVersionUID = 3010674519968303714L;
88
89 HttpHeaderDateFormatObsolete2() {
90 super("E MMM d HH:mm:ss yyyy", Locale.ENGLISH);
91 setTimeZone(TimeZone.getTimeZone("GMT"));
92 }
93 }
94 }