Sample extending Java 8 Temporal classes to render an ISO formatted string

suggest change

With this declaration:

fun Temporal.toIsoString(): String = DateTimeFormatter.ISO_INSTANT.format(this)

ISO_INSTANT only succeeds for temporal values that include an instant, such as Instant or OffsetDateTime. LocalDate throws DateTimeException.

You can now simply:

val dateAsString = someInstant.toIsoString()

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents