toInstant

fun OffsetDateTime.toInstant(): Instant
fun ZonedDateTime.toInstant(): Instant

Converts this date-time to an Instant representing the same time point.

fun String.toInstant(): Instant

Converts a string to an Instant.

The string is assumed to be an ISO-8601 UTC date-time representation in extended format. For example, 2010-10-05T18:30Z or 2010-10-05T18:30:00.123456789Z. The output of Instant.toString can be safely parsed using this method.

Throws

if the parsed date or time is invalid

fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant

Converts a string to an Instant using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Throws

if the parsed date or time is invalid