Sample extending Java 8 Temporal classes to render an ISO formatted string
suggest changeWith 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()
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents