Cannot resolve symbol 'ChronoUnit'

Answered

I updated my project to use OpenJDK 21.

My maven project builds but there's one particular import that the IDE can't find, which is:

import java.time.temporal.ChronoUnit;

I have tried

(1) Invalidate caches

(2) Repair IDE

(3) Removing SDK, adding it back again in Project Settings and Platform Settings

(4) Deleting .idea folder

Any help would be appreciated!

0
4 comments

Hello,

Which version of the IDEA you are using? Does it help when using the 2023.3 version which will be released this week at https://www.jetbrains.com/idea/nextversion/ ?

1

I also ran into this issue, and updated to the latest version. That resolved this issue.

0

I am on version 2022.2.5 (perpetual) with the same issue. Is there a fix for this version?

0

Hi Torgeir , at the time IDEA 2022.2.5 was released, JDK 21 had not yet been released. According to https://www.jetbrains.com/help/idea/2024.1/supported-java-versions.html#-6zw9rr_2, Java 21 has been supported since IntelliJ IDEA 2023.3. It is not possible to use an old IDE to support future JDK that comes from the future. So please try to upgrade to the latest version of IDEA or try JDK 17 to develop your project if no new features are used in JDK 21.

0

Please sign in to leave a comment.