Here you can find the source of formatHTTPDate(Date pTime)
Formats the time to a HTTP date, using the RFC 1123 format, as described in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3" >RFC 2616 (HTTP/1.1), sec.
Parameter | Description |
---|---|
pTime | the time |
public static String formatHTTPDate(Date pTime)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { /**//from w w w .j av a 2 s .c o m * RFC 1123 date format, as recommended by RFC 2616 (HTTP/1.1), sec 3.3 * NOTE: All date formats are private, to ensure synchronized access. */ private static final SimpleDateFormat HTTP_RFC1123_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); /** * Formats the time to a HTTP date, using the RFC 1123 format, as described * in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3" * >RFC 2616 (HTTP/1.1), sec. 3.3</a>. * * @param pTime the time * @return a {@code String} representation of the time */ public static String formatHTTPDate(long pTime) { return formatHTTPDate(new Date(pTime)); } /** * Formats the time to a HTTP date, using the RFC 1123 format, as described * in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3" * >RFC 2616 (HTTP/1.1), sec. 3.3</a>. * * @param pTime the time * @return a {@code String} representation of the time */ public static String formatHTTPDate(Date pTime) { synchronized (HTTP_RFC1123_FORMAT) { return HTTP_RFC1123_FORMAT.format(pTime); } } }