ISO
ISO 8601 extended format, which is the format used by YearMonth.toString and YearMonth.parse.
Examples of year-months in ISO 8601 format:
2020-08
+12020-08
0000-08
-0001-08
See ISO-8601-1:2019, 5.2.2.2a), using the "expanded calendar year" extension from 5.2.2.3b), generalized to any number of digits in the year for years that fit in an Int.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlinx.datetime.onDay
import kotlin.test.*
fun main() {
//sampleStart
// Using the extended ISO format for parsing and formatting YearMonth values
val yearMonth = YearMonth.Formats.ISO.parse("2024-04")
check(yearMonth == YearMonth(2024, Month.APRIL))
val formatted = YearMonth.Formats.ISO.format(yearMonth)
check(formatted == "2024-04")
//sampleEnd
}