Skip to content

Add non-throwing LocalDate(Time) construction & parsing #68

Open
@fluidsonic

Description

@fluidsonic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeThis could break existing code

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions