ChronoZonedDateTime query() method in Java with Examples Last Updated : 29 May, 2019 Comments Improve Suggest changes Like Article Like Report query() method of an ChronoZonedDateTime interface used to query this ChronoZonedDateTime using the specified query as parameter.The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this ChronoZonedDateTime. Syntax: default <R> R query(TemporalQuery<R> query) Parameters: This method accepts only one parameter query which is the query to invoke. Return value: This method returns the query result, null may be returned. Exception: This method throws following Exceptions: DateTimeException - if unable to query . ArithmeticException - if numeric overflow occurs. Below programs illustrate the query() method: Program 1: Java // Java program to demonstrate // ChronoZonedDateTime.query() method import java.time.*; import java.time.chrono.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create ChronoZonedDateTime object ChronoZonedDateTime zlt = ZonedDateTime.parse( "2018-10-25T23:12:31.123+02:00[Europe/Paris]"); // apply the query method of ChronoZonedDateTime class String value = zlt.query( TemporalQueries.precision()) .toString(); // print the result System.out.println("Precision value" + " for ChronoZonedDateTime is " + value); } } Output: Precision value for ChronoZonedDateTime is Nanos Program 2: Java // Java program to demonstrate // ChronoZonedDateTime.query() method import java.time.*; import java.time.chrono.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create ChronoZonedDateTime object ChronoZonedDateTime zlt = ZonedDateTime.parse( "2018-10-25T23:12:31.123+02:00[Europe/Paris]"); // apply query method of ChronoZonedDateTime class // print the result System.out.println("offset value for " + "ChronoZonedDateTime is " + zlt.query( TemporalQueries.offset())); } } Output: offset value for ChronoZonedDateTime is +02:00 References: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoZonedDateTime.html#query-java.time.temporal.TemporalQuery- Comment More infoAdvertise with us Next Article ChronoZonedDateTime query() method in Java with Examples S ShubhamMaurya3 Follow Improve Article Tags : Misc Java Java-Functions Java-ChronoZonedDateTime Java-Time-Chrono package +1 More Practice Tags : JavaMisc Similar Reads ChronoLocalDateTime query() method in Java with Examples query() method of an ChronoLocalDateTime interface is used to query this ChronoLocalDateTime using the specified query as parameter. The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this ChronoLocalDateTime. Syntax: default <R> R query(Temporal 2 min read ChronoZonedDateTime until() method in Java with Examples The until() method of the ChronoZonedDateTime interface used to calculate the amount of time between two ChronoZonedDateTime objects using TemporalUnit. The start and end points are this and the specified ChronoZonedDateTime passed as a parameter. The result will be negative if the end is before the 2 min read ChronoZonedDateTime get() method in Java with Examples The get() method of ChronoZonedDateTime interface in Java is used to get the value of the specified field passed as input from this ChronoZonedDateTime as an integer.This method queries this ChronoZonedDateTime for the value of the field and the returned value will always be within the valid range o 2 min read ChronoZonedDateTime from() method in Java with Examples The from() method of ChronoZonedDateTime interface in Java method obtains an instance of ChronoZonedDateTime from a temporal object. Syntax: static ChronoZonedDateTime from(TemporalAccessor temporal) Parameter: This method accepts a parameter temporal which specifies the temporal object to convert a 1 min read ChronoLocalDate query() Method in Java with Examples query() method of an ChronoLocalDate interface used to query this ChronoLocalDate using the specified query as parameter. The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this ChronoLocalDate. Syntax: public <R> R query(TemporalQuery<R> q 2 min read ChronoZonedDateTime equals() method in Java with Examples The equals() method of ChronoZonedDateTime interface in Java is used to compare this ChronoZonedDateTime to the another date-time object passed as parameter. The comparison is based on the offset date-time and the zone. Only objects of type ChronoZonedDateTime are compared with each other and other 2 min read ChronoZonedDateTime format() method in Java with Examples The format() method of ChronoZonedDateTime interface in Java is used to format this date-time using the specified formatter passed as parameter.This date-time will be passed to the formatter to produce a string. Syntax: default String format(DateTimeFormatter formatter) Parameters: This method accep 2 min read ChronoZonedDateTime isEqual() method in Java with Examples The isEqual() method of ChronoZonedDateTime interface in Java is used to check if the date, passed as the parameter, is equal to this ChronoZonedDateTime instance or not. It returns a boolean value showing the same. Syntax: default boolean isEqual(ChronoZonedDateTime otherDate) Parameter: This metho 2 min read ChronoZonedDateTime isAfter() method in Java with Examples The isAfter() method of ChronoZonedDateTime interface in Java is used to check if the date, passed as the parameter, is after this ChronoZonedDateTime instance or not. It returns a boolean value showing the same. Syntax: public boolean isAfter(ChronoZonedDateTime otherDate) Parameter: This method ac 2 min read ChronoZonedDateTime compareTo() method in Java with Examples The compareTo() method of ChronoZonedDateTime interface in Java method compares this date to another date. Syntax: default int compareTo(ChronoZonedDateTime other) Parameter: This method accepts a parameter other which specifies the other date to compare to and it is not specifically null. Return Va 2 min read Like