Java Date Time - ZonedDateTime query(TemporalQuery query) example








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

Syntax

query has the following syntax.

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

Example

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 = ZonedDateTime.now();
    LocalDate o =  dateTime.query(TemporalQueries.localDate());
    System.out.println(o);
  } 
}

The code above generates the following result.