Skip to content

//core/io.islandtime/toOffsetTime

toOffsetTime

common

fun OffsetDateTime.toOffsetTime(): OffsetTime

fun ZonedDateTime.toOffsetTime(): OffsetTime

Returns the combined time and UTC offset.

common

fun String.toOffsetTime(): OffsetTime

Converts a string to an OffsetTime.

The string is assumed to be an ISO-8601 time with the UTC offset in extended format. For example, 02:30+01:00 or 14:40:23Z. The output of OffsetTime.toString can be safely parsed using this method.

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed time or offset is invalid

common

fun String.toOffsetTime(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): OffsetTime

Converts a string to an OffsetTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Any custom parser must be capable of supplying the fields necessary to resolve both a Time and UtcOffset.

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed time or offset is invalid