to Local Date Time
Return the civil datetime value that this instant has in the time zone provided as an implicit receiver.
Note that while this conversion is unambiguous, the inverse (LocalDateTime.toInstant) is not necessarily so.
See also
Throws
if this value is too large to fit in LocalDateTime.
Samples
import kotlinx.datetime.*
import kotlinx.datetime.format.*
import kotlin.test.*
fun main() {
//sampleStart
// Converting an instant to a local date-time in a specific time zone
val zone = TimeZone.of("America/New_York")
val instant = Instant.parse("2023-06-02T12:30:00Z")
val localDateTime = with(zone) {
instant.toLocalDateTime()
}
check(localDateTime == LocalDate(2023, 6, 2).atTime(8, 30))
//sampleEnd
}