offset
An existing DateTimeFormat for the UTC offset part.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Using a predefined format for the UTC offset
val format = DateTimeComponents.Format {
dateTime(LocalDateTime.Formats.ISO)
offset(UtcOffset.Formats.FOUR_DIGITS)
}
val formatted = format.format {
setDateTimeOffset(
LocalDate(2021, 1, 13).atTime(9, 34, 58, 120_000_000),
UtcOffset(hours = 2)
)
}
check(formatted == "2021-01-13T09:34:58.12+0200")
//sampleEnd
}