FOUR_DIGITS
A subset of the ISO 8601 basic format that always outputs and parses exactly a numeric sign and four digits: two digits for the hour and two digits for the minute. If the offset has a non-zero number of seconds, they are truncated.
Examples of UTC offsets in this format:
+0000
+0500
-1716
+1036
See also
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Using the constant-width compact format for parsing and formatting UtcOffset values
val offset = UtcOffset.Formats.FOUR_DIGITS.parse("+1036")
check(offset == UtcOffset(hours = 10, minutes = 36))
val offsetWithSeconds = UtcOffset(hours = 10, minutes = 36, seconds = 59)
val formattedOffsetWithSeconds = UtcOffset.Formats.FOUR_DIGITS.format(offsetWithSeconds)
check(formattedOffsetWithSeconds == "+1036")
//sampleEnd
}