core / io.islandtime / kotlin.String / toZonedDateTime

toZonedDateTime

(iosArm64) fun String.toZonedDateTime(): ZonedDateTime
(iosX64) fun String.toZonedDateTime(): ZonedDateTime
(jvm) fun String.toZonedDateTime(): ZonedDateTime
(macosX64) fun String.toZonedDateTime(): ZonedDateTime

Convert a string to a ZonedDateTime.

The string is assumed to be a complete ISO-8601 date and time representation in extended format, optionally including a non-standard region ID. For example, 2005-05-06T23:30+01 or 2005-05-06T23:30-04:00[America/New_York].

The output of ZonedDateTime.toString can be safely parsed using this method.

Exceptions

DateTimeParseException - if parsing fails

DateTimeException - if the parsed time is invalid

(iosArm64) fun String.toZonedDateTime(parser: DateTimeParser): ZonedDateTime
(iosX64) fun String.toZonedDateTime(parser: DateTimeParser): ZonedDateTime
(jvm) fun String.toZonedDateTime(parser: DateTimeParser): ZonedDateTime
(macosX64) fun String.toZonedDateTime(parser: DateTimeParser): ZonedDateTime

Convert a string to a ZonedDateTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Exceptions

DateTimeParseException - if parsing fails

DateTimeException - if the parsed time is invalid