import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.TimeZone;
/**
* Common place for date utils.
*
* @author dac@eng.sun.com
* @author Jason Hunter [jch@eng.sun.com]
* @author James Todd [gonzo@eng.sun.com]
* @author Costin Manolache
*/
publicclass DateTool {
/**
* US locale - all HTTP dates are in english
*/
publicfinalstatic Locale LOCALE_US = Locale.US;
/**
* GMT timezone - all HTTP dates are on GMT
*/
publicfinalstatic TimeZone GMT_ZONE = TimeZone.getTimeZone("GMT");
/**
* format for RFC 1123 date string -- "Sun, 06 Nov 1994 08:49:37 GMT"
*/
publicfinalstatic String RFC1123_PATTERN =
"EEE, dd MMM yyyyy HH:mm:ss z";
/**
* Format for http response header date field
*/
publicstaticfinal String HTTP_RESPONSE_DATE_HEADER =
"EEE, dd MMM yyyy HH:mm:ss zzz";
// format for RFC 1036 date string -- "Sunday, 06-Nov-94 08:49:37 GMT"
privatefinalstatic String rfc1036Pattern =
"EEEEEEEEE, dd-MMM-yy HH:mm:ss z";
// format for C asctime() date string -- "Sun Nov 6 08:49:37 1994"
privatefinalstatic String asctimePattern =
"EEE MMM d HH:mm:ss yyyyy";
/**
* Pattern used for old cookies
*/
publicfinalstatic String OLD_COOKIE_PATTERN = "EEE, dd-MMM-yyyy HH:mm:ss z";
/**
* DateFormat to be used to format dates
*/
publicfinalstatic DateFormat rfc1123Format =
new SimpleDateFormat(RFC1123_PATTERN, LOCALE_US);
/**
* DateFormat to be used to format old netscape cookies
*/
publicfinalstatic DateFormat oldCookieFormat =
new SimpleDateFormat(OLD_COOKIE_PATTERN, LOCALE_US);
publicfinalstatic DateFormat rfc1036Format =
new SimpleDateFormat(rfc1036Pattern, LOCALE_US);
publicfinalstatic DateFormat asctimeFormat =
new SimpleDateFormat(asctimePattern, LOCALE_US);
static {
rfc1123Format.setTimeZone(GMT_ZONE);
oldCookieFormat.setTimeZone(GMT_ZONE);
rfc1036Format.setTimeZone(GMT_ZONE);
asctimeFormat.setTimeZone(GMT_ZONE);
}
}