of

actual fun of(zoneId: String): TimeZone(source)
expect fun of(zoneId: String): TimeZone(source)

Returns the time zone identified by the provided zoneId.

The supported variants of time zone identifiers:

  • Z, 'UTC', 'UT' or 'GMT' — identifies the fixed-offset time zone TimeZone.UTC,

  • a string starting with '+', '-', UTC+, UTC-, UT+, UT-, GMT+, GMT- — identifiers the time zone with the fixed offset specified after + or -,

  • all other strings are treated as region-based zone identifiers. In the IANA Time Zone Database (TZDB) which is used as the default source of time zones, these ids are usually in the form area/city, for example, Europe/Berlin or America/Los_Angeles.

It is guaranteed that passing any value from availableZoneIds to this function will return a valid time zone.

Throws

if zoneId has an invalid format or a time-zone with the name zoneId is not found.

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   // Constructing a time zone using the factory function
val zone = TimeZone.of("America/New_York")
check(zone.id == "America/New_York") 
   //sampleEnd
}
actual fun of(zoneId: String): TimeZone(source)
actual fun of(zoneId: String): TimeZone(source)