Returns the fixed-offset time zone with the given UTC offset.

Pitfall: UTC offsets are static values and do not change with time. If the logic requires that the offset changes with time, for example, to account for daylight-saving-time transitions, use TimeZone.of with a IANA time zone name to obtain a time zone that can handle changes in the offset.


import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() { 
   // Converting a UtcOffset to a fixed-offset TimeZone
UtcOffset(hours = 3, minutes = 30).asTimeZone().let { timeZone ->
    check( == "+03:30")
    check(timeZone.offset == UtcOffset(hours = 3, minutes = 30))