The list of methods to do HTTP Date are organized into topic(s).
String
getHttpDate() get Http Date
return getHttpDate(new Date());
String
gethttpDate() Generate an rfc822 date for use in the Date HTTP header.
final String DateFormat = "EEE, dd MMM yyyy HH:mm:ss ";
SimpleDateFormat format = new SimpleDateFormat(DateFormat, Locale.US);
format.setTimeZone(TimeZone.getTimeZone("GMT"));
return format.format(new Date()) + "GMT";
String
getHTTPDate() get the date according to the HTTP standard
DateFormat httpDateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.ENGLISH);
httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return httpDateFormat.format(new Date());
String
getHttpDate() convienence method returns current timestamp
return getHttpDate(new Date());
String
getHttpDate(int days) Format a date string in http-date format (1994年12月01日 16:00:00 GMT)
Calendar calendar = Calendar.getInstance();
long time = calendar.getTimeInMillis();
time += days * 24 * 60 * 60 * 1000L;
calendar.setTimeInMillis(time);
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
String ret = dateFormat.format(calendar.getTime());
return ret;
...
String
getHttpDate(long l) get Http Date
return getDateString(l, "EEE, d MMM yyyy HH:mm:ss") + " GMT";
long
getHttpDate(String date) Returns long representation of the HTTP defined RFC 1123 date format.
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
try {
return dateFormat.parse(date).getTime();
} catch (Exception e) {
return -1;
Date
getHttpDate(String value) get Http Date
if (value == null) {
return null;
Date result = null;
try {
result = getCxfHttpDateFormat().parse(value);
} catch (ParseException ex) {
try {
...
SimpleDateFormat
getHttpDateFormat() get Http Date Format
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
TimeZone tZone = TimeZone.getTimeZone("GMT");
dateFormat.setTimeZone(tZone);
return dateFormat;