Class Cookie.CookieDate

java.lang.Object
org.simpleframework.http.Cookie.CookieDate
Enclosing class:
Cookie

private static class Cookie.CookieDate extends Object
The CookieDate complies with the date format used by older browsers such as Internet Explorer and Netscape Navigator. The format of the date is not the same as other HTTP date headers. It takes the form.
 
    DAY, DD-MMM-YYYY HH:MM:SS GMT
 
 
Support for this format is required as many browsers do not support max-age and so cookies will not expire for these browsers.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final DateFormat
    This is the date formatter used to build the string.
    private static final String
    This is the format that is required for the date.
    private final TimeZone
    This is the GMT time zone which must be used.
    private static final String
    The cookie date must be returned in the GMT zone.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the CookieDate formatter.
  • Method Summary

    Modifier and Type
    Method
    Description
    private Date
    convert(int seconds)
    This method is used to convert the provided time to a date that can be formatted.
    format(int seconds)
    This takes the number of seconds the cookie will live for.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FORMAT

      private static final String FORMAT
      This is the format that is required for the date.
      See Also:
    • ZONE

      private static final String ZONE
      The cookie date must be returned in the GMT zone.
      See Also:
    • format

      private final DateFormat format
      This is the date formatter used to build the string.
    • zone

      private final TimeZone zone
      This is the GMT time zone which must be used.
  • Constructor Details

    • CookieDate

      public CookieDate()
      Constructor for the CookieDate formatter. This creates the time zone and date formatting tools that are need to convert the expiry in seconds to the correct text format for older browsers to understand.
  • Method Details

    • format

      public String format(int seconds)
      This takes the number of seconds the cookie will live for. In order for this to be respected by older browsers such as IE-5.0 to IE-9.0 this must return a string in the original cookie specification by Netscape.
      Parameters:
      seconds - the number of seconds from now
      Returns:
      a date formatted for used with old browsers
    • convert

      private Date convert(int seconds)
      This method is used to convert the provided time to a date that can be formatted. The time returned is the current time plus the number of seconds provided.
      Parameters:
      seconds - the number of seconds from now
      Returns:
      a date representing some time in the future