Java Date Time - Month query(TemporalQuery query) example








Month query(TemporalQuery<R> query) queries this month-of-year object 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.Month;
import java.time.chrono.Chronology;
import java.time.temporal.TemporalQueries;
//w  ww. ja v  a2 s  .  c o  m
public class Main {
  public static void main(String[] args) {
    Month m = Month.from(LocalDate.now());
    
    Chronology n = m.query(TemporalQueries.chronology());
    System.out.println(n);

  }
}

The code above generates the following result.