Esempio di metodo java.time.Instant.query ()

Descrizione

Il java.time.Instant.query(TemporalQuery query) il metodo interroga questo istante utilizzando la query specificata.

Dichiarazione

Di seguito è riportata la dichiarazione per java.time.Instant.query(TemporalQuery query) metodo.

public 
      
        R query(TemporalQuery
       
         query) 
       
      

Parameters

query − the query to invoke, not null.

Return Value

the query result, null may be returned (defined by the query).

Exceptions

  • DateTimeException − if unable to query (defined by the query).

  • ArithmeticException − if numeric overflow occurs (defined by the query).

Example

The following example shows the usage of java.time.Instant.query(TemporalQuery query) method.

package com.tutorialspoint;

import java.time.Instant;
import java.time.temporal.TemporalQueries;

public class InstantDemo {
   public static void main(String[] args) {

      Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
      System.out.printf("Instant precision is %s%n",
         instant.query(TemporalQueries.precision()));
   }
}

Let us compile and run the above program, this will produce the following result −

Instant precision is Nanos