Skip to content

//core/io.islandtime.ranges/toOffsetDateTimeInterval

toOffsetDateTimeInterval

common

fun ZonedDateTimeInterval.toOffsetDateTimeInterval(): OffsetDateTimeInterval

Converts this interval to an OffsetDateTimeInterval.

While similar to ZonedDateTime, an OffsetDateTime representation is unaffected by time zone rule changes or database differences between systems, making it better suited for use cases involving persistence or network transfer.

common

fun String.toOffsetDateTimeInterval(): OffsetDateTimeInterval

Converts a string to an OffsetDateTimeInterval.

The string is assumed to be an ISO-8601 time interval representation in extended format. The output of OffsetDateTimeInterval.toString can be safely parsed using this method.

Examples:

  • `1990-01-04T03-05/1991-08-30T15:30:05.123-04:00`
  • `../1991-08-30T15:30:05.123-04:00`
  • `1990-01-04T03-05/..`
  • `../..`
  • (empty string)

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed time is invalid

common

fun String.toOffsetDateTimeInterval(parser: GroupedDateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): OffsetDateTimeInterval

Converts a string to an OffsetDateTimeInterval using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed interval is invalid