Class Cookie.CookieDate

  • Enclosing class:
    Cookie

    private static class Cookie.CookieDate
    extends java.lang.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 java.text.DateFormat format
      This is the date formatter used to build the string.
      private static java.lang.String FORMAT
      This is the format that is required for the date.
      private java.util.TimeZone zone
      This is the GMT time zone which must be used.
      private static java.lang.String ZONE
      The cookie date must be returned in the GMT zone.
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.Date convert​(int seconds)
      This method is used to convert the provided time to a date that can be formatted.
      java.lang.String 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 Detail

      • FORMAT

        private static final java.lang.String FORMAT
        This is the format that is required for the date.
        See Also:
        Constant Field Values
      • ZONE

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

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

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

      • 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 Detail

      • format

        public java.lang.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 java.util.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