com.google.gdata.data
Class DateTime

java.lang.Object
  extended by com.google.gdata.data.DateTime
All Implemented Interfaces:
java.lang.Comparable

public class DateTime
extends java.lang.Object
implements java.lang.Comparable

Represents a date/time, or a date without a time. Optionally includes a time zone.


Field Summary
protected  boolean dateOnly
          Specifies whether this is a date-only value.
static java.util.regex.Pattern datePattern
          XML date pattern.
static java.util.regex.Pattern dateTimeChoicePattern
          XML date/time or date pattern.
static java.util.regex.Pattern dateTimePattern
          XML date/time pattern.
protected  java.lang.Integer tzShift
          Time zone shift from UTC in minutes.
protected  long value
          Date/time value expressed as the number of ms since the Unix epoch.
 
Constructor Summary
DateTime()
           
DateTime(java.util.Date value)
           
DateTime(java.util.Date value, java.util.TimeZone zone)
           
DateTime(long value)
           
DateTime(long value, int tzShift)
           
 
Method Summary
 int compareTo(java.lang.Object o)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Integer getTzShift()
           
 long getValue()
           
 int hashCode()
           
 boolean isDateOnly()
           
static DateTime now()
           
static DateTime parseDate(java.lang.String str)
          Parses an xs:date string.
static DateTime parseDateTime(java.lang.String str)
          Parses an xs:dateTime string.
static DateTime parseDateTimeChoice(java.lang.String value)
          Parses an XML value that's either an xs:date or xs:dateTime string.
 void setDateOnly(boolean v)
           
 void setTzShift(java.lang.Integer v)
           
 void setValue(long v)
           
 java.lang.String toString()
          Formats the value as an xs:date or xs:dateTime string.
 java.lang.String toStringRfc822()
          Formats the value as an RFC 822 date/time.
 java.lang.String toUiString()
          Formats the value as a human-readable string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

protected long value
Date/time value expressed as the number of ms since the Unix epoch. If the time zone is specified, this value is normalized to UTC, so to format this date/time value, the time zone shift has to be applied.


dateOnly

protected boolean dateOnly
Specifies whether this is a date-only value.


tzShift

protected java.lang.Integer tzShift
Time zone shift from UTC in minutes. If null, no time zone is set, and the time is always interpreted as local time.


dateTimePattern

public static final java.util.regex.Pattern dateTimePattern
XML date/time pattern.


datePattern

public static final java.util.regex.Pattern datePattern
XML date pattern.


dateTimeChoicePattern

public static final java.util.regex.Pattern dateTimeChoicePattern
XML date/time or date pattern.

Constructor Detail

DateTime

public DateTime()

DateTime

public DateTime(long value)

DateTime

public DateTime(java.util.Date value)

DateTime

public DateTime(long value,
                int tzShift)

DateTime

public DateTime(java.util.Date value,
                java.util.TimeZone zone)
Method Detail

now

public static DateTime now()

getValue

public long getValue()

setValue

public void setValue(long v)

isDateOnly

public boolean isDateOnly()

setDateOnly

public void setDateOnly(boolean v)

getTzShift

public java.lang.Integer getTzShift()

setTzShift

public void setTzShift(java.lang.Integer v)

hashCode

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

equals

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

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Formats the value as an xs:date or xs:dateTime string.

Overrides:
toString in class java.lang.Object

toStringRfc822

public java.lang.String toStringRfc822()
Formats the value as an RFC 822 date/time.


toUiString

public java.lang.String toUiString()
Formats the value as a human-readable string.


parseDateTime

public static DateTime parseDateTime(java.lang.String str)
                              throws java.lang.NumberFormatException
Parses an xs:dateTime string.

Throws:
java.lang.NumberFormatException

parseDate

public static DateTime parseDate(java.lang.String str)
                          throws java.lang.NumberFormatException
Parses an xs:date string.

Throws:
java.lang.NumberFormatException

parseDateTimeChoice

public static DateTime parseDateTimeChoice(java.lang.String value)
                                    throws java.lang.NumberFormatException
Parses an XML value that's either an xs:date or xs:dateTime string.

Throws:
java.lang.NumberFormatException - Invalid RFC 3339 date or date/time string.