Java Utililty Methods Date RFC Format

List of utility methods to do Date RFC Format

Description

The list of methods to do Date RFC Format are organized into topic(s).

Method

Dateget3339Date(String rfc3339Date)
get Date
Date date = null;
try {
    if (rfc3339Date.endsWith("Z")) {
        try {
            final SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
            date = s.parse(rfc3339Date);
        } catch (final java.text.ParseException pe) { 
            final SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'");
...
StringgetRFC1123Date()
Retrieves the current date suitable for RFC 1123
return rfc1123.format(Calendar.getInstance().getTime());
DateFormatgetRfc1123DateFormat()
Creates a new instance of a DateFormat for RFC1123 compliant dates.
final DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
format.setLenient(false);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format;
StringgetRFC2616Date(Date date)
get RFC Date
Date nowDate = date;
if (null == date) {
    nowDate = new Date();
SimpleDateFormat df = new SimpleDateFormat(FORMAT_RFC2616, Locale.ENGLISH);
df.setTimeZone(new SimpleTimeZone(0, TIME_ZONE));
return df.format(nowDate);
StringgetRFC3339String(Calendar timestamp)
Takes a timestamp as a Calendar and returns it as a String in RFC 3339 format.
SimpleDateFormat rfc3339Formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
return rfc3339Formatter.format(timestamp.getTime());
DateFormatgetRFC822()
See RFC822 section 5.
return new SimpleDateFormat("EEE', 'dd' 'MMM' 'yy' 'HH:mm:ss' 'Z", Locale.US);
StringgetRFC822Date()
Get the RFC822-compliant representation of the current time
return getRFC822Date(new Date());
DateFormatgetRfc822DateFormat()
get Rfc Date Format
SimpleDateFormat rfc822DateFormat = new SimpleDateFormat(RFC822_DATE_FORMAT, Locale.US);
rfc822DateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
return rfc822DateFormat;
SimpleDateFormatgetRfc822DateFormat()
get Rfc Date Format
return new SimpleDateFormat(formatRfc822, Locale.US);
StringgetRfc822DateStringGMT(Date date)
get Rfc Date String GMT
String pattern = RFC_822_ZONE_LESS_FORMAT.toPattern();
SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.US);
StringBuilder r = new StringBuilder();
format.setTimeZone(TimeZone.getTimeZone("GMT"));
r.append(format.format(date));
r.append(" GMT");
return r.toString();