Usage of API documented as @since1.6+
You may also need to ensure that your project has build/release set to the right java version. Without that, you may see an error like this:
Error:java: javacTask: source release 1.8 requires target release 1.8
The way to fix it for maven project is to enable build plugin in your pom file. This SO answer has specifics.
File
> Project Structure
> Project Settings
> Modules
> your Module name
> Sources
> Language Level
> choose the one which you need.
This warning is produced by the Java | Java language level migration aids | Usages of API which isn't available at the configured language level
inspection. By default this inspection looks at the language level configured for the project, and warns on any api used that was not available in the JDK version matching the language level. Most likely your project's or module's language level is not configured correctly in the Project Structure
settings.