com.google.api.client.util
Class DateTime

java.lang.Object
  extended by com.google.api.client.util.DateTime
All Implemented Interfaces:
Serializable

public final class DateTime
extends Object
implements Serializable

Immutable representation of a date with an optional time and an optional time zone based on RFC 3339.

Implementation is immutable and therefore thread-safe.

Upgrade warning: in prior version 1.4 this class was not final, but now it is final to ensure its immutability.

Since:
1.0
Author:
Yaniv Inbar
See Also:
Serialized Form

Field Summary
 boolean dateOnly
          Deprecated. (scheduled to be made private in 1.6) Use isDateOnly()
 Integer tzShift
          Deprecated. (scheduled to be made private in 1.6) Use getTimeZoneShift()
 long value
          Deprecated. (scheduled to be made private in 1.6) Use getValue()
 
Constructor Summary
DateTime(boolean dateOnly, long value, Integer tzShift)
           
DateTime(Date value)
           
DateTime(Date date, TimeZone zone)
           
DateTime(long value)
           
DateTime(long value, Integer tzShift)
           
 
Method Summary
 boolean equals(Object o)
           
 Integer getTimeZoneShift()
          Returns the time zone shift from UTC in minutes or null for local time zone.
 long getValue()
          Returns the date/time value expressed as the number of milliseconds since the Unix epoch.
 boolean isDateOnly()
          Returns whether this is a date-only value.
static DateTime parseRfc3339(String str)
          Parses an RFC 3339 date/time value.
 String toString()
           
 String toStringRfc3339()
          Formats the value as an RFC 3339 date/time string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

@Deprecated
public final long value
Deprecated. (scheduled to be made private in 1.6) Use getValue()
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

@Deprecated
public final boolean dateOnly
Deprecated. (scheduled to be made private in 1.6) Use isDateOnly()
Specifies whether this is a date-only value.


tzShift

@Deprecated
public final Integer tzShift
Deprecated. (scheduled to be made private in 1.6) Use getTimeZoneShift()
Time zone shift from UTC in minutes. If null, no time zone is set, and the time is always interpreted as local time.

Constructor Detail

DateTime

public DateTime(Date date,
                TimeZone zone)

DateTime

public DateTime(long value)

DateTime

public DateTime(Date value)

DateTime

public DateTime(long value,
                Integer tzShift)

DateTime

public DateTime(boolean dateOnly,
                long value,
                Integer tzShift)
Method Detail

getValue

public long getValue()
Returns the date/time value expressed as the number of milliseconds 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.

Since:
1.5

isDateOnly

public boolean isDateOnly()
Returns whether this is a date-only value.

Since:
1.5

getTimeZoneShift

public Integer getTimeZoneShift()
Returns the time zone shift from UTC in minutes or null for local time zone.

Since:
1.5

toStringRfc3339

public String toStringRfc3339()
Formats the value as an RFC 3339 date/time string.


toString

public String toString()
Overrides:
toString in class Object

equals

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

parseRfc3339

public static DateTime parseRfc3339(String str)
                             throws NumberFormatException
Parses an RFC 3339 date/time value.

Throws:
NumberFormatException


Copyright © 2011 Google. All Rights Reserved.