/** * Can be used to parse http times. For instance something like a http * header Date: Tue, 26 Mar 2013 13:47:13 GMT * * @param httpDateFormat in http format: Date: Tue, 26 Mar 2013 13:47:13 GMT * @return A nice "DateTime" (JodaTime) object containing that http * timestamp. * @throws ParseException If something goes wrong. */ public static Date parseHttpDateFormatToDateTime(String httpDateFormat) throws ParseException { return getRFC1123_DateFormat().parse(httpDateFormat); }
/** * Can be used to format a date into http header compatible strings. * <p/> * It can be used to generate something like: Date: Wed, 05 Sep 2012 * 09:16:19 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT * * @param date The date to format * @return a http header compatible string like * "Thu, 01 Jan 1970 00:00:00 GMT" */ public static String formatForHttpHeader(Date date) { return getRFC1123_DateFormat().format(date); }
/** * Can be used to format a unix timestamp into http header compatible * strings. * <p/> * It can be used to generate something like: Date: Wed, 05 Sep 2012 * 09:16:19 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT * * @param unixTime The long (unixtime) to format * @return a http header compatible string like * "Thu, 01 Jan 1970 00:00:00 GMT" */ public static String formatForHttpHeader(long unixTime) { return getRFC1123_DateFormat().format(new Date(unixTime)); }