public class

DateTime

extends Object
implements Comparable<T>
java.lang.Object
   ↳ com.google.gdata.data.DateTime

Class Overview

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

Summary

Fields
private static final TimeZone GMT
protected boolean dateOnly Specifies whether this is a date-only value.
public static final Pattern datePattern XML date pattern.
public static final Pattern dateTimeChoicePattern XML date/time or date pattern.
private static final SimpleDateFormat dateTimeFormat822 RFC 822 date/time format.
public static final Pattern dateTimePattern XML date/time pattern.
protected 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.
Public Constructors
DateTime()
DateTime(long value)
DateTime(Date value)
DateTime(long value, int tzShift)
DateTime(Date value, TimeZone zone)
Public Methods
int compareTo(Object o)
boolean equals(Object o)
Compares instance with DateTime or Date objects.
Integer getTzShift()
long getValue()
int hashCode()
boolean isDateOnly()
static DateTime now()
static DateTime parseDate(String str)
Parses an xs:date string.
static DateTime parseDateTime(String str)
Parses an xs:dateTime string.
static DateTime parseDateTimeChoice(String value)
Parses an XML value that's either an xs:date or xs:dateTime string.
static DateTime parseRfc822(String str)
Parses the value as an RFC 822 date/time.
void setDateOnly(boolean v)
void setTzShift(Integer v)
void setValue(long v)
String toString()
Formats the value as an xs:date or xs:dateTime string.
String toStringRfc822()
Formats the value as an RFC 822 date/time.
String toUiString()
Formats the value as a human-readable string.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Fields

private static final TimeZone GMT

protected boolean dateOnly

Specifies whether this is a date-only value.

public static final Pattern datePattern

XML date pattern.

public static final Pattern dateTimeChoicePattern

XML date/time or date pattern.

private static final SimpleDateFormat dateTimeFormat822

RFC 822 date/time format.

public static final Pattern dateTimePattern

XML date/time pattern.

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

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.

Public Constructors

public DateTime ()

public DateTime (long value)

Parameters
value

public DateTime (Date value)

Parameters
value

public DateTime (long value, int tzShift)

Parameters
value
tzShift

public DateTime (Date value, TimeZone zone)

Parameters
value
zone

Public Methods

public int compareTo (Object o)

Parameters
o

public boolean equals (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.

Parameters
o

public Integer getTzShift ()

public long getValue ()

public int hashCode ()

public boolean isDateOnly ()

public static DateTime now ()

public static DateTime parseDate (String str)

Parses an xs:date string.

Parameters
str
Throws
NumberFormatException

public static DateTime parseDateTime (String str)

Parses an xs:dateTime string.

Parameters
str
Throws
NumberFormatException

public static DateTime parseDateTimeChoice (String value)

Parses an XML value that's either an xs:date or xs:dateTime string.

Parameters
value
Throws
NumberFormatException Invalid RFC 3339 date or date/time string.

public static DateTime parseRfc822 (String str)

Parses the value as an RFC 822 date/time.

Parameters
str

public void setDateOnly (boolean v)

Parameters
v

public void setTzShift (Integer v)

Parameters
v

public void setValue (long v)

Parameters
v

public String toString ()

Formats the value as an xs:date or xs:dateTime string.

public String toStringRfc822 ()

Formats the value as an RFC 822 date/time.

public String toUiString ()

Formats the value as a human-readable string.