setDateTimeOffset

fun setDateTimeOffset(instant: Instant, utcOffset: UtcOffset)(source)

Writes the contents of the specified instant to this DateTimeComponents.

This method is almost always equivalent to the following code:

setDateTime(instant.toLocalDateTime(offset))
setOffset(utcOffset)

However, this also works for instants that are too large to be represented as a LocalDateTime.

If any of the fields are already set, they will be overwritten.


fun setDateTimeOffset(localDateTime: LocalDateTime, utcOffset: UtcOffset)(source)

Writes the contents of the specified localDateTime and utcOffset to this DateTimeComponents.

A shortcut for calling setDateTime and setOffset separately.

If localDateTime is obtained from an Instant using LocalDateTime.toInstant, it is recommended to use setDateTimeOffset that accepts an Instant directly.