简体   繁体   English

ofInstant 不是对象 java.time.LocalDate 的成员

[英]ofInstant is not a member of object java.time.LocalDate

I have following scala code:我有以下scala代码:

LocalDate.ofInstant(instant, zoneId)

instant is java.time.Instant, zoneId is java.time.ZoneId. Instant 是 java.time.Instant,zoneId 是 java.time.ZoneId。

Intellij project is configured to jdk 17 and language level to 15. Intellij 项目配置为 jdk 17,语言级别为 15。

But I get error:但我得到错误:

value ofInstant is not a member of object java.time.LocalDate

I am unable to find why.我找不到原因。 Java versions are correct one I think.我认为 Java 版本是正确的。

在 Java 8 中从 Instant 获取 LocalDate 可以执行以下操作

 LocalDate localDate = LocalDate.from(ZonedDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM