toInstant

fun String.toInstant(): Instant

Converts this string representing an instant in ISO-8601 format including date and time components and the time zone offset to an Instant value.

See Instant.parse for examples of instant string representations and discussion of leap seconds.

Throws

if the text cannot be parsed or the boundaries of Instant are exceeded.


expect fun LocalDateTime.toInstant(timeZone: TimeZone): Instant

Returns an instant that corresponds to this civil date/time value in the specified timeZone.

Note that the conversion is not always unambiguous. There can be the following possible situations:

  • There's only one instant that has this date/time value in the timeZone. In this case the conversion is unambiguous.

  • There's no instant that has this date/time value in the timeZone. Such situation appears when the time zone experiences a transition from a lesser to a greater offset. In this case the conversion is performed with the lesser offset.

  • There are two possible instants that can have this date/time components in the timeZone. In this case the earlier instant is returned.

See also


expect fun LocalDateTime.toInstant(offset: UtcOffset): Instant

Returns an instant that corresponds to this civil date/time value that happens at the specified UTC offset.

See also

actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
actual fun LocalDateTime.toInstant(offset: UtcOffset): Instant
actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
actual fun LocalDateTime.toInstant(offset: UtcOffset): Instant
actual fun LocalDateTime.toInstant(timeZone: TimeZone): Instant
actual fun LocalDateTime.toInstant(offset: UtcOffset): Instant