org.apache.abdera.model
Class AtomDate

java.lang.Object
  extended by org.apache.abdera.model.AtomDate

public final class AtomDate
extends java.lang.Object

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.
  


Constructor Summary
AtomDate()
           
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
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.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
static java.lang.String format(java.util.Date d)
          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
static java.util.Date parse(java.lang.String date)
          Parse the serialized string form into a java.util.Date
 void setValue(java.util.Calendar calendar)
          Sets the value of the Atom date using java.util.Calendar
 void setValue(java.util.Date date)
          Sets the value of the Atom date using java.util.Date
 void setValue(long timestamp)
          Sets the value of the Atom date using the number of milliseconds since January 1, 1970, 00:00:00 GMT
 void setValue(java.lang.String value)
          Sets the value of the Atom date using the serialized string form
 java.lang.String toString()
           
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
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomDate

public AtomDate()

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

AtomDate

public AtomDate(java.util.Calendar value)
Create an AtomDate using a java.util.Calendar.

Parameters:
value - The java.util.Calendar value

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 void 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 void setValue(java.util.Date date)
Sets the value of the Atom date using java.util.Date

Parameters:
date - A java.util.Date

setValue

public void setValue(java.util.Calendar calendar)
Sets the value of the Atom date using java.util.Calendar

Parameters:
calendar - a java.util.Calendar

setValue

public void 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

equals

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

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 d)
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