List of utility methods to do Date RFC Format
Date | get3339Date(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'"); ... |
String | getRFC1123Date() Retrieves the current date suitable for RFC 1123 return rfc1123.format(Calendar.getInstance().getTime());
|
DateFormat | getRfc1123DateFormat() 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; |
String | getRFC2616Date(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); |
String | getRFC3339String(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()); |
DateFormat | getRFC822() See RFC822 section 5. return new SimpleDateFormat("EEE', 'dd' 'MMM' 'yy' 'HH:mm:ss' 'Z", Locale.US); |
String | getRFC822Date() Get the RFC822-compliant representation of the current time return getRFC822Date(new Date()); |
DateFormat | getRfc822DateFormat() get Rfc Date Format SimpleDateFormat rfc822DateFormat = new SimpleDateFormat(RFC822_DATE_FORMAT, Locale.US); rfc822DateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); return rfc822DateFormat; |
SimpleDateFormat | getRfc822DateFormat() get Rfc Date Format return new SimpleDateFormat(formatRfc822, Locale.US); |
String | getRfc822DateStringGMT(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(); |