public final class DateTime extends Object implements Serializable
Implementation is immutable and therefore thread-safe.
Constructor and Description |
---|
DateTime(boolean dateOnly,
long value,
Integer tzShift) |
DateTime(Date value) |
DateTime(Date date,
TimeZone zone) |
DateTime(long value) |
DateTime(long value,
Integer tzShift) |
DateTime(String value)
|
Modifier and Type | Method and Description |
---|---|
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.
|
public DateTime(long value)
public DateTime(Date value)
public DateTime(long value, Integer tzShift)
public DateTime(boolean dateOnly, long value, Integer tzShift)
public DateTime(String value)
public long getValue()
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 boolean isDateOnly()
public Integer getTimeZoneShift()
null
for local time zone.public String toStringRfc3339()
public boolean equals(Object o)
A check is added that the time zone is the same. If you ONLY want to check equality of time
value, check equality on the getValue()
.
public static DateTime parseRfc3339(String str) throws NumberFormatException
For the date-only case, the time zone is ignored and the hourOfDay, minute, second, and millisecond parameters are set to zero.
NumberFormatException
Copyright © 2011-2012 Google. All Rights Reserved.