toZonedDateTime

fun OffsetDateTime.toZonedDateTime(zone: TimeZone, strategy: OffsetConversionStrategy): ZonedDateTime

Converts this OffsetDateTime to a ZonedDateTime using the specified strategy to adjust it to a valid date, time, and offset in zone.

Alternatively, you can use asZonedDateTime to convert to a ZonedDateTime with an equivalent fixed-offset zone. However, this comes with the caveat that a fixed-offset zone lacks knowledge of any region and will not respond to daylight savings time changes.

See also

fun String.toZonedDateTime(): ZonedDateTime

Converts a string to a ZonedDateTime.

The string is assumed to be a complete ISO-8601 date and time representation in extended format, optionally including a non-standard region ID. For example, 2005-05-06T23:30+01 or 2005-05-06T23:30-04:00[America/New_York].

The output of ZonedDateTime.toString can be safely parsed using this method.

Throws

if the parsed date-time is invalid

fun String.toZonedDateTime(parser: DateTimeParser, settings: DateTimeParserSettings = DateTimeParserSettings.DEFAULT): ZonedDateTime

Converts a string to a ZonedDateTime using a specific parser.

A set of predefined parsers can be found in DateTimeParsers.

Throws

if the parsed date-time is invalid