Skip to content

//core/io.islandtime.ranges/toDateTimeInterval

toDateTimeInterval

common

fun OffsetDateTimeInterval.toDateTimeInterval(): DateTimeInterval

fun ZonedDateTimeInterval.toDateTimeInterval(): DateTimeInterval

Returns this interval with the precision reduced to only the local date and time.

common

fun String.toDateTimeInterval(): DateTimeInterval

Converts a string to a DateTimeInterval.

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

Examples:

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

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed time is invalid

common

fun String.toDateTimeInterval(parser: GroupedDateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): DateTimeInterval

Converts a string to a DateTimeInterval 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