FileDocCategorySizeDatePackage
HttpDateGenerator.javaAPI DocAndroid 1.5 API2754Wed May 06 22:41:10 BST 2009org.apache.http.protocol

HttpDateGenerator

public class HttpDateGenerator extends Object
Generates a date in the format required by the HTTP protocol.
author
Oleg Kalnichevski
version
$Revision: 548066 $
since
4.0

Fields Summary
public static final String
PATTERN_RFC1123
Date format pattern used to generate the header in RFC 1123 format.
public static final TimeZone
GMT
The time zone to use in the date header.
private final DateFormat
dateformat
private long
dateAsLong
private String
dateAsText
Constructors Summary
public HttpDateGenerator()


      
        super();
        this.dateformat = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);
        this.dateformat.setTimeZone(GMT);
    
Methods Summary
public synchronized java.lang.StringgetCurrentDate()

        long now = System.currentTimeMillis();
        if (now - this.dateAsLong > 1000) {
            // Generate new date string
            this.dateAsText = this.dateformat.format(new Date(now));
            this.dateAsLong = now;
        }
        return this.dateAsText;