ISO_BASIC

ISO 8601 basic format.

An extension of ISO 8601 that allows parsing and formatting seconds.

When formatting, seconds are omitted if they are zero. If the whole offset is zero, the letter Z is output.

Examples of UTC offsets in ISO 8601 basic format:

  • Z

  • +05

  • -1716

  • +103630

See ISO-8601-1:2019, 4.3.13a) and b), extended to support seconds-of-minute when they are non-zero.

See also

Samples

import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Using the basic ISO format for parsing and formatting UtcOffset values
val offset = UtcOffset.Formats.ISO_BASIC.parse("+103622")
check(offset == UtcOffset(hours = 10, minutes = 36, seconds = 22))
val formatted = UtcOffset.Formats.ISO_BASIC.format(offset)
check(formatted == "+103622") 
   //sampleEnd
}