Google Data APIs Client Library (1.41.1)



com.google.gdata.data
Class DateTime

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

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

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)
          Compares instance with DateTime or Date objects.
 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.
static DateTime parseRfc822(java.lang.String str)
          Parses the value as an RFC 822 date/time.
 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)
Compares instance with DateTime or Date objects. Does not take the tzShift value into account. Therefore, two DateTime objects are equal independent to the time zone they refer to. Equals with a instance of java.util.Date is asymmetric.

Overrides:
equals in class java.lang.Object

compareTo

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

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.


parseRfc822

public static DateTime parseRfc822(java.lang.String str)
                            throws ParseException
Parses the value as an RFC 822 date/time.

Throws:
ParseException

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.