KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > util > DateTool


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina.util;
20
21 import java.text.DateFormat JavaDoc;
22 import java.text.SimpleDateFormat JavaDoc;
23 import java.util.Locale JavaDoc;
24 import java.util.TimeZone JavaDoc;
25
26 /**
27  * Common place for date utils.
28  *
29  * @author dac@eng.sun.com
30  * @author Jason Hunter [jch@eng.sun.com]
31  * @author James Todd [gonzo@eng.sun.com]
32  * @author Costin Manolache
33  */

34 public class DateTool {
35
36     private static StringManager sm =
37         StringManager.getManager("org.apache.catalina.util");
38
39     /**
40      * US locale - all HTTP dates are in english
41      */

42     public final static Locale JavaDoc LOCALE_US = Locale.US;
43
44     /**
45      * GMT timezone - all HTTP dates are on GMT
46      */

47     public final static TimeZone JavaDoc GMT_ZONE = TimeZone.getTimeZone("GMT");
48
49     /**
50      * format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
51      */

52     public final static String JavaDoc RFC1123_PATTERN =
53         "EEE, dd MMM yyyyy HH:mm:ss z";
54
55     /**
56      * Format for http response header date field
57      */

58     public static final String JavaDoc HTTP_RESPONSE_DATE_HEADER =
59         "EEE, dd MMM yyyy HH:mm:ss zzz";
60
61     // format for RFC 1036 date string -- "Sunday, 06-Nov-94 08:49:37 GMT"
62
private final static String JavaDoc rfc1036Pattern =
63         "EEEEEEEEE, dd-MMM-yy HH:mm:ss z";
64
65     // format for C asctime() date string -- "Sun Nov 6 08:49:37 1994"
66
private final static String JavaDoc asctimePattern =
67         "EEE MMM d HH:mm:ss yyyyy";
68
69     /**
70      * Pattern used for old cookies
71      */

72     public final static String JavaDoc OLD_COOKIE_PATTERN = "EEE, dd-MMM-yyyy HH:mm:ss z";
73
74     /**
75      * DateFormat to be used to format dates
76      */

77     public final static DateFormat JavaDoc rfc1123Format =
78         new SimpleDateFormat JavaDoc(RFC1123_PATTERN, LOCALE_US);
79
80     /**
81      * DateFormat to be used to format old netscape cookies
82      */

83     public final static DateFormat JavaDoc oldCookieFormat =
84         new SimpleDateFormat JavaDoc(OLD_COOKIE_PATTERN, LOCALE_US);
85
86     public final static DateFormat JavaDoc rfc1036Format =
87         new SimpleDateFormat JavaDoc(rfc1036Pattern, LOCALE_US);
88
89     public final static DateFormat JavaDoc asctimeFormat =
90         new SimpleDateFormat JavaDoc(asctimePattern, LOCALE_US);
91
92     static {
93         rfc1123Format.setTimeZone(GMT_ZONE);
94         oldCookieFormat.setTimeZone(GMT_ZONE);
95         rfc1036Format.setTimeZone(GMT_ZONE);
96         asctimeFormat.setTimeZone(GMT_ZONE);
97     }
98
99 }
100
Popular Tags