ISO_BASIC

ISO 8601 basic format.

Examples of dates in ISO 8601 basic format:

  • 20200830

  • +120200830

  • 00000830

  • -00010830

See ISO-8601-1:2019, 5.2.2.1a), 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 basic ISO format for parsing and formatting LocalDate values
val date = LocalDate.Formats.ISO_BASIC.parse("20240416")
check(date == LocalDate(2024, Month.APRIL, 16))
val formatted = LocalDate.Formats.ISO_BASIC.format(date)
check(formatted == "20240416") 
   //sampleEnd
}