Konrad von Jungingen
Konrad von Jungingen

Reputation: 171

Java - Cannot resolve symbol of in LocalDate.of

import java.time.LocalDate;

public class Main {
    public static void main(String[] args) {
        LocalDate ld = new LocalDate.of(2000,10,20);
    }
}

I'm using IntelliJ IDEA Community Edition 15.0.3. When I try to use LocalDate.of it shows "Cannot resolve symbol 'of'". I tried typing "o" and then enter but it still doesn't work. When trying to compile and run it says:

"Error:(14, 37) java: cannot find symbol 
symbol:   class of
location: class java.time.LocalDate"

Upvotes: 14

Views: 19369

Answers (1)

rgettman
rgettman

Reputation: 178293

Because of your new operator, you are attempting to instantiate a nested class called of within LocalDate, which does not exist.

Remove new so it can parse as the static method of within LocalDate.

LocalDate ld =  LocalDate.of(2000,10,20);

Upvotes: 27

Related Questions