Hi there If this line: `val birthDate = LocalDate...
# getting-started
p
Hi there If this line:
val birthDate = LocalDate.parse("2000-3-10")
throws the following exception:
Exception in thread "main" kotlinx.datetime.DateTimeFormatException: java.time.format.DateTimeParseException: Text '2000-3-10' could not be parsed at index 5
, why I can't do that:
Copy code
package org.example

import kotlinx.datetime.LocalDate
import kotlinx.datetime.DateTimeFormatException

fun main() {
    try {
        val birthDate = LocalDate.parse("2000-3-10")
    } catch (e: DateTimeFormatException) {
        // ...
    }
}
? It raises the following error:
Cannot access 'DateTimeFormatException': it is internal in 'kotlinx.datetime'
What am I missing? Thank you
Also, importing this
import java.time.format.DateTimeParseException
instead, does not work
a
You can catch
IllegalArgumentException
instead. https://github.com/Kotlin/kotlinx-datetime/issues/153
👍 1