ehonsey
02/09/2017, 11:35 PMjava.sql.Date
. Although I have an import for that class in the calling class, when I call Date.from(Instant)
the compiler is inferring java.util.Date
instead of java.sql.Date
. I had to give a type hint. I would have expected the compiler to make this inference based on the type of the target field.ilya.gorbunov
02/10/2017, 12:29 AMehonsey
02/10/2017, 3:48 PMimport java.sql.Date
import java.time.Instant
class SqlDateWrapper(sqlDate: Date)
fun typeInferenceError() {
val wrapper = SqlDateWrapper(Date.from(Instant.now()))
}
Date.from
. My original Kotlin compiler version was 1.0.4. However, the same error showed on 1.0.6ilya.gorbunov
02/10/2017, 3:55 PMjava.sql.Date
extends java.util.Date
. There is no static from
method in JDK, that returns java.sql.Date
, only the one that returns java.util.Date
. So when you call java.sql.Date.from
, you actually refer to java.util.Date.from
, and thus you get java.util.Date
as a result.ehonsey
02/10/2017, 3:59 PMjava.time.Instant
to a java.sql.Date
for my JPA entity. Ugh