org.apache.abdera.model
Class AtomDate

java.lang.Object
  extended by org.apache.abdera.model.AtomDate
All Implemented Interfaces:
Serializable, Cloneable

public final class AtomDate
extends Object
implements Cloneable, 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
AtomDate()
          Create an AtomDate using the current date and time
AtomDate(Calendar value)
          Create an AtomDate using a java.util.Calendar.
AtomDate(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(String value)
          Create an AtomDate using the serialized string format (e.g. 2003-12-13T18:30:02Z).
 
Method Summary
 Object clone()
           
 boolean equals(Object obj)
           
static String format(Date date)
          Create the serialized string form from a java.util.Date
 Calendar getCalendar()
          Returns the value of this Atom Date as a java.util.Calendar
 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
 String getValue()
          Return the serialized string form of the Atom date
 int hashCode()
           
static Date parse(String date)
          Parse the serialized string form into a java.util.Date
 AtomDate setValue(Calendar calendar)
          Sets the value of the Atom date using java.util.Calendar
 AtomDate setValue(Date date)
          Sets the value of the Atom date using 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(String value)
          Sets the value of the Atom date using the serialized string form
 String toString()
           
static AtomDate valueOf(Calendar value)
          Create a new Atom Date instance from a java.util.Calendar
static AtomDate valueOf(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(String value)
          Create a new Atom Date instance from the serialized string form
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomDate

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


AtomDate

public AtomDate(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(Date value)
Create an AtomDate using a java.util.Date

Parameters:
value - The java.util.Date value
Throws:
NullPointerException - if date is null

AtomDate

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

Parameters:
value - The java.util.Calendar value
Throws:
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 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(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(Date date)
Sets the value of the Atom date using java.util.Date

Parameters:
date - A java.util.Date
Throws:
NullPointerException - if date is null

setValue

public AtomDate setValue(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 Date getDate()
Returns the value of this Atom Date

Returns:
A java.util.Date representing this Atom Date

getCalendar

public 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 String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

clone

public Object clone()
Overrides:
clone in class Object

parse

public static Date parse(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 String format(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(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(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(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


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.