MCPcopy Index your code
hub / github.com/apache/tomcat / FastHttpDateFormat

Class FastHttpDateFormat

java/org/apache/tomcat/util/http/FastHttpDateFormat.java:29–189  ·  view source on GitHub ↗

Utility class to generate HTTP dates.

Source from the content-addressed store, hash-verified

27 * Utility class to generate HTTP dates.
28 */
29public final class FastHttpDateFormat {
30
31 /**
32 * Private constructor to prevent instantiation. This is a utility class with only static methods.
33 */
34 private FastHttpDateFormat() {
35 }
36
37
38 // -------------------------------------------------------------- Variables
39
40
41 private static final int CACHE_SIZE =
42 Integer.getInteger("org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE", 1000).intValue();
43
44
45 // HTTP date formats
46 private static final String DATE_RFC5322 = "EEE, dd MMM yyyy HH:mm:ss z";
47 private static final String DATE_OBSOLETE_RFC850 = "EEEEEE, dd-MMM-yy HH:mm:ss zzz";
48 private static final String DATE_OBSOLETE_ASCTIME = "EEE MMMM d HH:mm:ss yyyy";
49
50 private static final ConcurrentDateFormat FORMAT_RFC5322;
51 private static final ConcurrentDateFormat FORMAT_OBSOLETE_RFC850;
52 private static final ConcurrentDateFormat FORMAT_OBSOLETE_ASCTIME;
53
54 private static final ConcurrentDateFormat[] httpParseFormats;
55
56 static {
57 // All the formats that use a timezone use GMT
58 TimeZone tz = TimeZone.getTimeZone("GMT");
59
60 FORMAT_RFC5322 = new ConcurrentDateFormat(DATE_RFC5322, Locale.US, tz);
61 FORMAT_OBSOLETE_RFC850 = new ConcurrentDateFormat(DATE_OBSOLETE_RFC850, Locale.US, tz);
62 FORMAT_OBSOLETE_ASCTIME = new ConcurrentDateFormat(DATE_OBSOLETE_ASCTIME, Locale.US, tz);
63
64 httpParseFormats =
65 new ConcurrentDateFormat[] { FORMAT_RFC5322, FORMAT_OBSOLETE_RFC850, FORMAT_OBSOLETE_ASCTIME };
66 }
67
68 /**
69 * Instant on which the currentDate object was generated.
70 */
71 private static volatile long currentDateGeneratedInSeconds = 0L;
72
73
74 /**
75 * Current formatted date.
76 */
77 private static String currentDate = null;
78
79
80 /**
81 * Formatter cache.
82 * <p>
83 * Note: This needs to be a ConcurrentHashMap for correct operation so declare it as such (rather than as Map).
84 */
85 private static final ConcurrentHashMap<Long,String> formatCache = new ConcurrentHashMap<>(CACHE_SIZE);
86

Callers

nothing calls this directly

Calls 2

getIntegerMethod · 0.80
getTimeZoneMethod · 0.80

Tested by

no test coverage detected