core / io.islandtime / kotlin.String / toTime

toTime

(iosArm64) fun String.toTime(): Time
(iosX64) fun String.toTime(): Time
(jvm) fun String.toTime(): Time
(macosX64) fun String.toTime(): Time

Convert a string to a Time.

The string is assumed to be an ISO-8601 time representation in extended format. For example, 05, 05:30, 05:30:00, or 05:30:00.123456789. The output of Time.toString can be safely parsed using this method.

Exceptions

DateTimeParseException - if parsing fails

DateTimeException - if the parsed time is invalid

(iosArm64) fun String.toTime(parser: DateTimeParser): Time
(iosX64) fun String.toTime(parser: DateTimeParser): Time
(jvm) fun String.toTime(parser: DateTimeParser): Time
(macosX64) fun String.toTime(parser: DateTimeParser): Time

Convert a string to a Time 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