Open In App

OffsetTime query() method in Java with examples

Last Updated : 25 Aug, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

The Query() method of OffsetTime class in Java queries this time using the specified query.

Syntax : 

public  R query(TemporalQuery query)

Parameter: This method accepts a single parameter query that specifies the query to be invoked and not null. 

Return Value: It returns the query result, null may be returned (defined by the query). 

Errors and Exceptions: The function throws two exceptions which are described below:  

  • DateTimeException: it is thrown if it is unable to query.
  • ArithmeticException: it is thrown if a numeric overflow occurs.

Below programs illustrate the query() method:

Program 1 :  


Output: 
OffsetTime precision is Nanos

 

Program 2 : 


Output: 
OffsetTime precision is Nanos

 

Reference: https://docs.oracle.com/javase/8/docs/api/java/time/OffsetTime.html#query-java.time.temporal.TemporalQuery-
 


Next Article
Practice Tags :

Similar Reads