DateTimeWithZone


@CarProtocol
class 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 and create are provided for convenience if using java.util and java.time respectively. If using another library such as Joda time, create can be used.

Summary

Public functions

java-static DateTimeWithZone
@RequiresApi(value = 26)
create(zonedDateTime: ZonedDateTime)

Returns an instance of a DateTimeWithZone.

java-static DateTimeWithZone
create(timeSinceEpochMillis: Long, timeZone: TimeZone)

Returns an instance of a DateTimeWithZone.

java-static DateTimeWithZone
create(
    timeSinceEpochMillis: Long,
    zoneOffsetSeconds: @IntRange(from = "-64800", to = 64800) Int,
    zoneShortName: String
)

Returns an instance of a DateTimeWithZone.

Boolean
equals(other: Any?)
Long

Returns the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.

Int

Returns the offset of the time zone from UTC.

String?

Returns the abbreviated name of the time zone, for example "PST" for Pacific Standard Time.

Int
String

Public functions

create

Added in 1.0.0
@RequiresApi(value = 26)
java-static fun create(zonedDateTime: ZonedDateTime): DateTimeWithZone

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
java.lang.NullPointerException

if zonedDateTime is null

create

Added in 1.0.0
java-static fun create(timeSinceEpochMillis: Long, timeZone: TimeZone): DateTimeWithZone

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
java.lang.IllegalArgumentException

if timeSinceEpochMillis is a negative value

java.lang.NullPointerException

if timeZone is null

create

Added in 1.0.0
java-static fun create(
    timeSinceEpochMillis: Long,
    zoneOffsetSeconds: @IntRange(from = "-64800", to = 64800) Int,
    zoneShortName: String
): DateTimeWithZone

Returns an instance of a DateTimeWithZone.

Parameters
timeSinceEpochMillis: Long

The number of milliseconds from the epoch of 1970-01-01T00:00:00Z

zoneOffsetSeconds: @IntRange(from = "-64800", to = 64800) 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 +64800

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
java.lang.IllegalArgumentException

if timeSinceEpochMillis is a negative value, if zoneOffsetSeconds is not within the required range, or if zoneShortName is empty

java.lang.NullPointerException

if zoneShortName is null

equals

fun equals(other: Any?): Boolean

getTimeSinceEpochMillis

Added in 1.0.0
fun getTimeSinceEpochMillis(): Long

Returns the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.

getZoneOffsetSeconds

Added in 1.0.0
fun getZoneOffsetSeconds(): Int

Returns the offset of the time zone from UTC.

getZoneShortName

Added in 1.0.0
fun getZoneShortName(): String?

Returns the abbreviated name of the time zone, for example "PST" for Pacific Standard Time.

hashCode

fun hashCode(): Int

toString

fun toString(): String