Open
Description
There should be null
-returning variants for creating LocalDate(Time)
instances. It shouldn't be necessary to catch an exception. This is especially useful when creating instances from user input.
val date = runCatching { LocalDate(userInput.year, userInput.month, userInput.day) }.getOrNull()
Also:
Instant.parse(…)
TimeZone.of(…)
- etc.
Just like all similar stdlib functions have …OrNull
variants.
https://elizarov.medium.com/kotlin-and-exceptions-8062f589d07