TimeZone

A time zone.

sealed class TimeZone : Comparable<TimeZone>

Types

Companion
Link copied to clipboard
common
object Companion
FixedOffset
Link copied to clipboard
common

A time zone defined by a fixed offset from UTC.

In general, region-based time zones are preferred, but there are situations where only a fixed offset may be available.

class FixedOffset : TimeZone
Region
Link copied to clipboard
common

A named time zone, typically corresponding to a region identifier in the IANA Time Zone Database, but may be any name that can be understood by a TimeZoneRulesProvider.

class Region : TimeZone

Functions

compareTo
Link copied to clipboard
common
open operator override fun compareTo(other: TimeZone): Int
displayName
Link copied to clipboard
common

A textual representation of this time zone, suitable for display purposes. The localized name will be returned, if available for the locale in the specified style. If not, the id will be returned instead.

The result depends on the configured TimeZoneTextProvider and may differ between platforms.

Example output for the "America/New_York" ID and "en-US" locale:

  • Standard: "Eastern Standard Time"

  • Short standard: "EST"

  • Daylight Saving: "Eastern Daylight Time"

  • Short daylight saving: "EDT"

  • Generic: "Eastern Time"

  • Short generic: "ET"

fun displayName(style: TimeZoneTextStyle, locale: Locale): String
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
localizedName
Link copied to clipboard
common

The localized name of this time zone, if available for the locale in the specified style. The result depends on the configured TimeZoneTextProvider and may differ between platforms.

Example output for the "America/New_York" ID and "en-US" locale:

  • Standard: "Eastern Standard Time"

  • Short standard: "EST"

  • Daylight Saving: "Eastern Daylight Time"

  • Short daylight saving: "EDT"

  • Generic: "Eastern Time"

  • Short generic: "ET"

fun localizedName(style: TimeZoneTextStyle, locale: Locale): String?
normalized
Link copied to clipboard
common

Returns a normalized time zone, converting any zone with a fixed offset to use a consistent identifier.

abstract fun normalized(): TimeZone
toString
Link copied to clipboard
common

Returns the id of this time zone.

open override fun toString(): String
validate
Link copied to clipboard
common

Checks if this time zone is valid and throws an exception if it isn't.

fun validate()
validated
Link copied to clipboard
common

Ensures that this time zone is valid, throwing an exception if it isn't.

fun validated(): TimeZone

Properties

id
Link copied to clipboard
common

An ID that uniquely identifies the time zone.

abstract val id: String
isValid
Link copied to clipboard
common

Checks if this is a valid time zone according to the current time zone rules provider.

abstract val isValid: Boolean
rules
Link copied to clipboard
common

The rules associated with this time zone.

abstract val rules: TimeZoneRules

Inheritors

TimeZone
Link copied to clipboard
common
TimeZone
Link copied to clipboard
common

Extensions

toJavaZoneId
Link copied to clipboard

Converts this time zone to an equivalent Java ZoneId.

fun TimeZone.toJavaZoneId(): ZoneId
toNSTimeZone
Link copied to clipboard
darwin

Converts this time zone to an NSTimeZone.

fun TimeZone.toNSTimeZone(): <ERROR CLASS>
toNSTimeZoneOrNull
Link copied to clipboard
darwin

Converts this time zone to an NSTimeZone, or null if the identifier isn't recognized as valid for an NSTimeZone.

fun TimeZone.toNSTimeZoneOrNull(): <ERROR CLASS>?