ISO

ISO 8601 extended format, which is the format used by LocalDate.toString and LocalDate.parse.

Examples of dates in ISO 8601 format:

  • 2020-08-30

  • +12020-08-30

  • 0000-08-30

  • -0001-08-30

See ISO-8601-1:2019, 5.2.2.1b), using the "expanded calendar year" extension from 5.2.2.3a), 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 kotlin.random.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // Using the extended ISO format for parsing and formatting LocalDate values
val date = LocalDate.Formats.ISO.parse("2024-04-16")
check(date == LocalDate(2024, Month.APRIL, 16))
val formatted = LocalDate.Formats.ISO.format(date)
check(formatted == "2024-04-16") 
   //sampleEnd
}