SPACE
Pad with spaces during formatting. During parsing, padding is required; otherwise, parsing fails.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Defining a custom format that uses spaces for padding
val format = LocalDate.Format {
monthNumber(Padding.SPACE)
char('/')
dayOfMonth()
char(' ')
year()
}
val leoFirstReignStart = LocalDate(457, 2, 7)
check(leoFirstReignStart.format(format) == " 2/07 0457")
// providing leading zeros on parsing instead of spaces is allowed:
check(LocalDate.parse(" 2/07 0457", format) == leoFirstReignStart)
check(LocalDate.parse("02/07 0457", format) == leoFirstReignStart)
//sampleEnd
}