Java Date Time - OffsetDateTime query(TemporalQuery query) example

OffsetDateTime 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.OffsetDateTime;
import java.time.temporal.TemporalQueries;
/*from www .  j a va2*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o =;
    LocalDate d =  o.query(TemporalQueries.localDate());

The code above generates the following result.