Java Date Time - ZonedDateTime query(TemporalQuery query) example

ZonedDateTime query(TemporalQuery<R> query) queries this date-time using the specified query.


query has the following syntax.

public <R> R query(TemporalQuery<R> query)


The following example shows how to use query.

import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalQueries;
/*w w  w.ja  v  a 2s.c  om*/
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =;
    LocalDate o =  dateTime.query(TemporalQueries.localDate());

The code above generates the following result.