Java 8 documentation

The Oracle Tutorial page for Temporal Query page shows this sample code.

- The 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 an error:

- Mistake

 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 if this java 8 documentation tutorial example is true or not, but I copy this code segment and paste in my IDE and then the IDE gives an error.

+2
java java-time
Oct 24 '17 at 5:48 on
source share
2 answers

Change this line TemporalQueries query = TemporalQueries.precision(); at TemporalQuery<TemporalUnit> query = TemporalQueries.precision();

You can check this Java 9 documentation

+1
Oct 24 '17 at 5:55 on
source share

There is an error in the code. Look what Lokesh said.

To further study coding, make sure you understand the error correctly. It will make your life easier. In this example, the error says: TemporalQuery<TemporalUnit> cannot be converted to TemporalQueries

If you check your code, <TemporalUnit> does not exist, which indicates that you should put it somewhere and in the right place so that it is mentioned by Lokesh.

You can go through the tutorial

+1
Oct 24 '17 at 6:00
source share



All Articles