简体   繁体   English

IntelliJ IDEA 15无法识别java.time

[英]IntelliJ IDEA 15 not recognizing java.time

I have the current version of IntelliJ Idea and have already checked that the SDK is 1.8. 我具有IntelliJ Idea的当前版本,并且已经检查SDK是否为1.8。 However, when I import java.time.*, all of the methods are red and give the message "Cannot resolve symbol", despite there not being an error on the actual import. 但是,当我导入java.time。*时,尽管实际导入没有错误,但所有方法均为红色,并显示消息“无法解析符号”。 I have included a screenshot of my code instead of a nicely formatted version of my code because I believe the error is with Intellij/Java and not the actual code itself. 我包括了我的代码的屏幕快照,而不是我的代码的格式很好的版本,因为我相信错误是Intellij / Java引起的,而不是实际的代码本身。 If more detail is needed I can provide screenshots of the settings. 如果需要更多详细信息,我可以提供设置的屏幕截图。 I just don't know how to proceed and I haven't been able to find anything on the internet that answers my question. 我只是不知道如何进行,也无法在互联网上找到任何可以回答我问题的东西。

这是一张图片或问题

The error has nothing to do with IntelliJ. 该错误与IntelliJ无关。 now() is a static method of LocalDateTime so you should call (without the new ): now()LocalDateTime的静态方法,因此您应该调用(没有new ):

LocalDateTime ldt = LocalDateTime.now();

Your call with new keyword makes the compiler search for an inner class named now within the LocalDateTime class which it wants to instantiate. 使用new关键字进行的调用使编译器在要实例化的LocalDateTime类中搜索一个now命名的内部类。

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

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