The Oracle Tutorial page for the Temporal Query show this example code.
- Code
TemporalQueries query = TemporalQueries.precision();
System.out.printf("LocalDate precision is %s%n",LocalDate.now().query(query));
When I compile this segment code, the Compiler throws the error:
- Error
TemporalQueryExample.java:8: error: incompatible types: TemporalQuery<TemporalUnit> cannot be converted to TemporalQueries
TemporalQueries query = TemporalQueries.precision();
^
TemporalQueryExample.java:10: error: no suitable method found for query(TemporalQueries)
LocalDate.now().query(query));
^
I don't know this java 8 documentation tutorial example is correct or not but I copy this code segment and paste my IDE then IDE throw the Error.
There is an error in the code. Look at what Lokesh has mentioned.
To further learn coding, make sure you understand the error properly. It will make your life easier. In this example, the error says:
TemporalQuery<TemporalUnit>
cannot be converted toTemporalQueries
If you check your code,
<TemporalUnit>
is not there, which is an indication that you have to place it somewhere and the right place to have it is mentioned by Lokesh.You can go through this tutorial
Change this line
TemporalQueries query = TemporalQueries.precision();
to thisTemporalQuery<TemporalUnit> query = TemporalQueries.precision();
You can check this Java 9 documentation