Class AtomDate

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public final class AtomDate
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable

    Provides an implementation of the Atom Date Construct, which is itself a specialization of the RFC3339 date-time.

    Accessors on this class are not synchronized.

    Per RFC4287:

      3.3.  Date Constructs
     
      A Date construct is an element whose content MUST conform to the
      "date-time" production in [RFC3339].  In addition, an uppercase "T"
      character MUST be used to separate date and time, and an uppercase
      "Z" character MUST be present in the absence of a numeric time zone
      offset.
     
      atomDateConstruct =
         atomCommonAttributes,
         xsd:dateTime
     
      Such date values happen to be compatible with the following
      specifications: [ISO.8601.1988], [W3C.NOTE-datetime-19980827], and
      [W3C.REC-xmlschema-2-20041028].
     
      Example Date constructs:
     
      <updated>2003-12-13T18:30:02Z</updated>
      <updated>2003-12-13T18:30:02.25Z</updated>
      <updated>2003-12-13T18:30:02+01:00</updated>
      <updated>2003-12-13T18:30:02.25+01:00</updated>
     
      Date values SHOULD be as accurate as possible.  For example, it would
      be generally inappropriate for a publishing system to apply the same
      timestamp to several entries that were published during the course of
      a single day.
     
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      AtomDate()
      Create an AtomDate using the current date and time
      AtomDate​(long value)
      Create an AtomDate using the number of milliseconds since January 1, 1970, 00:00:00 GMT
      AtomDate​(java.lang.String value)
      Create an AtomDate using the serialized string format (e.g.
      AtomDate​(java.util.Calendar value)
      Create an AtomDate using a java.util.Calendar.
      AtomDate​(java.util.Date value)
      Create an AtomDate using a java.util.Date
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object clone()  
      boolean equals​(java.lang.Object obj)  
      static java.lang.String format​(java.util.Date date)
      Create the serialized string form from a java.util.Date
      java.util.Calendar getCalendar()
      Returns the value of this Atom Date as a java.util.Calendar
      java.util.Date getDate()
      Returns the value of this Atom Date
      long getTime()
      Returns the value of this Atom Date as the number of milliseconds since January 1, 1970, 00:00:00 GMT
      java.lang.String getValue()
      Return the serialized string form of the Atom date
      int hashCode()  
      static java.util.Date parse​(java.lang.String date)
      Parse the serialized string form into a java.util.Date
      AtomDate setValue​(long timestamp)
      Sets the value of the Atom date using the number of milliseconds since January 1, 1970, 00:00:00 GMT
      AtomDate setValue​(java.lang.String value)
      Sets the value of the Atom date using the serialized string form
      AtomDate setValue​(java.util.Calendar calendar)
      Sets the value of the Atom date using java.util.Calendar
      AtomDate setValue​(java.util.Date date)
      Sets the value of the Atom date using java.util.Date
      java.lang.String toString()  
      static AtomDate valueOf​(long value)
      Create a new Atom Date instance using the number of milliseconds since January 1, 1970, 00:00:00 GMT
      static AtomDate valueOf​(java.lang.String value)
      Create a new Atom Date instance from the serialized string form
      static AtomDate valueOf​(java.util.Calendar value)
      Create a new Atom Date instance from a java.util.Calendar
      static AtomDate valueOf​(java.util.Date value)
      Create a new Atom Date instance from a java.util.Date
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AtomDate

        public AtomDate()
        Create an AtomDate using the current date and time
      • AtomDate

        public AtomDate​(java.lang.String value)
        Create an AtomDate using the serialized string format (e.g. 2003-12-13T18:30:02Z).
        Parameters:
        value - The serialized RFC3339 date/time value
      • AtomDate

        public AtomDate​(java.util.Date value)
        Create an AtomDate using a java.util.Date
        Parameters:
        value - The java.util.Date value
        Throws:
        java.lang.NullPointerException - if date is null
      • AtomDate

        public AtomDate​(java.util.Calendar value)
        Create an AtomDate using a java.util.Calendar.
        Parameters:
        value - The java.util.Calendar value
        Throws:
        java.lang.NullPointerException - if value is null
      • AtomDate

        public AtomDate​(long value)
        Create an AtomDate using the number of milliseconds since January 1, 1970, 00:00:00 GMT
        Parameters:
        value - The number of milliseconds since January 1, 1970, 00:00:00 GMT
    • Method Detail

      • getValue

        public java.lang.String getValue()
        Return the serialized string form of the Atom date
        Returns:
        the serialized string form of the date as specified by RFC4287
      • setValue

        public AtomDate setValue​(java.lang.String value)
        Sets the value of the Atom date using the serialized string form
        Parameters:
        value - The serialized string form of the date
      • setValue

        public AtomDate setValue​(java.util.Date date)
        Sets the value of the Atom date using java.util.Date
        Parameters:
        date - A java.util.Date
        Throws:
        java.lang.NullPointerException - if date is null
      • setValue

        public AtomDate setValue​(java.util.Calendar calendar)
        Sets the value of the Atom date using java.util.Calendar
        Parameters:
        calendar - a java.util.Calendar
      • setValue

        public AtomDate setValue​(long timestamp)
        Sets the value of the Atom date using the number of milliseconds since January 1, 1970, 00:00:00 GMT
        Parameters:
        timestamp - The number of milliseconds since January 1, 1970, 00:00:00 GMT
      • getDate

        public java.util.Date getDate()
        Returns the value of this Atom Date
        Returns:
        A java.util.Date representing this Atom Date
      • getCalendar

        public java.util.Calendar getCalendar()
        Returns the value of this Atom Date as a java.util.Calendar
        Returns:
        A java.util.Calendar representing this Atom Date
      • getTime

        public long getTime()
        Returns the value of this Atom Date as the number of milliseconds since January 1, 1970, 00:00:00 GMT
        Returns:
        The number of milliseconds since January 1, 1970, 00:00:00 GMT
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • clone

        public java.lang.Object clone()
      • parse

        public static java.util.Date parse​(java.lang.String date)
        Parse the serialized string form into a java.util.Date
        Parameters:
        date - The serialized string form of the date
        Returns:
        The created java.util.Date
      • format

        public static java.lang.String format​(java.util.Date date)
        Create the serialized string form from a java.util.Date
        Parameters:
        d - A java.util.Date
        Returns:
        The serialized string form of the date
      • valueOf

        public static AtomDate valueOf​(java.lang.String value)
        Create a new Atom Date instance from the serialized string form
        Parameters:
        value - The serialized string form of the date
        Returns:
        The created AtomDate
      • valueOf

        public static AtomDate valueOf​(java.util.Date value)
        Create a new Atom Date instance from a java.util.Date
        Parameters:
        value - a java.util.Date
        Returns:
        The created AtomDate
      • valueOf

        public static AtomDate valueOf​(java.util.Calendar value)
        Create a new Atom Date instance from a java.util.Calendar
        Parameters:
        value - A java.util.Calendar
        Returns:
        The created AtomDate
      • valueOf

        public static AtomDate valueOf​(long value)
        Create a new Atom Date instance using the number of milliseconds since January 1, 1970, 00:00:00 GMT
        Parameters:
        value - The number of milliseconds since January 1, 1970, 00:00:00 GMT
        Returns:
        The created AtomDate