Skip to content

//core/io.islandtime/toDateTime

toDateTime

common

fun String.toDateTime(): DateTime

Convert a string to a DateTime.

The string is assumed to be an ISO-8601 date-time representation in extended format. For example, 2019-08-22T18:00 or 2019-08-22 18:00:30.123456789. The output of DateTime.toString can be safely parsed using this method.

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed date-time is invalid

common

fun String.toDateTime(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): DateTime

Converts a string to a DateTime 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 Date and Time.

Throws

DateTimeParseException if parsing fails
DateTimeException if the parsed date-time is invalid