DateTimeWithZone
public
final
class
DateTimeWithZone
extends Object
| java.lang.Object
|
| ↳ |
androidx.car.app.model.DateTimeWithZone
|
A time with an associated time zone information.
In order to avoid time zone databases being out of sync between the app and the host, this
model avoids using IANA database time zone IDs and
instead relies on the app passing the time zone offset and its abbreviated name. Apps can use
their time library of choice to retrieve the time zone information.
create(long, TimeZone) and create(ZonedDateTime) are provided for
convenience if using java.util and java.time respectively. If using another
library such as Joda time, create(long, int, String) can be used.
Summary
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
Public methods
create
public static DateTimeWithZone create (long timeSinceEpochMillis,
TimeZone timeZone)
Returns an instance of a DateTimeWithZone.
| Parameters |
timeSinceEpochMillis |
long: The number of milliseconds from the epoch of
1970-01-01T00:00:00Z |
timeZone |
TimeZone: The time zone at the date specified by timeInUtcMillis.
The abbreviated name of this time zone, formatted using the
default locale, may be displayed to the user when needed, for
example, if this time zone is different than the current
system time zone |
| Throws |
IllegalArgumentException |
if timeSinceEpochMillis is a negative value |
NullPointerException |
if timeZone is null
|
create
public static DateTimeWithZone create (ZonedDateTime zonedDateTime)
Returns an instance of a DateTimeWithZone.
| Parameters |
zonedDateTime |
ZonedDateTime: The time with a time zone. The abbreviated name of this time zone,
formatted using the default locale, may be displayed to the user when
needed, for example, if this time zone is different than the current
system time zone |
| Throws |
NullPointerException |
if zonedDateTime is null
|
create
public static DateTimeWithZone create (long timeSinceEpochMillis,
int zoneOffsetSeconds,
String zoneShortName)
Returns an instance of a DateTimeWithZone.
| Parameters |
timeSinceEpochMillis |
long: The number of milliseconds from the epoch of
1970-01-01T00:00:00Z |
zoneOffsetSeconds |
int: The offset of the time zone from UTC at the date specified by
timeInUtcMillis. This offset must be in the range
-18:00 to +18:00, which corresponds to -64800
to +64800Value is between -64800 and 64800 inclusive. |
zoneShortName |
String: The abbreviated name of the time zone, for example, "PST" for
Pacific Standard Time. This string may be used to display to
the user along with the date when needed, for example, if this
time zone is different than the current system time zone |
| Throws |
IllegalArgumentException |
if timeSinceEpochMillis is a negative value, if
zoneOffsetSeconds is not within the required range,
or if zoneShortName is empty |
NullPointerException |
if zoneShortName is null
|
equals
public boolean equals (Object other)
getTimeSinceEpochMillis
public long getTimeSinceEpochMillis ()
Returns the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.
getZoneOffsetSeconds
public int getZoneOffsetSeconds ()
Returns the offset of the time zone from UTC.
getZoneShortName
public String getZoneShortName ()
Returns the abbreviated name of the time zone, for example "PST" for Pacific Standard
Time.
hashCode
public int hashCode ()
toString
public String toString ()