user1868744
user1868744

Reputation: 1033

Kotlin: Unresolved reference: ofInstant

I am new to Kotlin and I am trying to compile an open source code, that is written in Kotlin. The build using gradle is failing with error:

Unresolved reference: ofInstant

This is the line that is causing the error:

package common.time
import java.time.*
private val UTC = ZoneId.of("UTC")
fun Instant.toUtcLocalDate() = LocalDate.ofInstant(this, UTC)

I have the latest JDK installed. Any help is appreciated. Thanks

Upvotes: 0

Views: 1958

Answers (1)

Tenfour04
Tenfour04

Reputation: 93619

LocalDate.ofInstant() is only in Java 9 and later. You can use ZonedDateTime.ofInstant(this, UTC).toLocalDate() instead.

Upvotes: 1

Related Questions