core / io.islandtime / kotlin.String / toInstant

toInstant

(iosArm64) fun String.toInstant(): Instant
(iosX64) fun String.toInstant(): Instant
(jvm) fun String.toInstant(): Instant
(macosX64) fun String.toInstant(): Instant
(tvosArm64) fun String.toInstant(): Instant
(tvosX64) fun String.toInstant(): Instant
(watchosArm64) fun String.toInstant(): Instant
(watchosX86) 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.

Exceptions

DateTimeParseException - if parsing fails

DateTimeException - if the parsed date or time is invalid

(iosArm64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(iosX64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(jvm) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(macosX64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(tvosArm64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(tvosX64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(watchosArm64) fun String.toInstant(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): Instant
(watchosX86) 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.

Exceptions

DateTimeParseException - if parsing fails

DateTimeException - if the parsed date or time is invalid