Java Date Time - Year query(TemporalQuery query) example








Year query(TemporalQuery<R> query) queries this year 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.Year;
import java.time.chrono.Chronology;
import java.time.temporal.TemporalQueries;
//w w  w . ja  va  2 s  . c o  m
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    Chronology l = y.query(TemporalQueries.chronology());
    System.out.println(l);

  }
}

The code above generates the following result.