YearMonth query(TemporalQuery query) example

Description

YearMonth query(TemporalQuery<R> query) queries this year-month 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.YearMonth;
import java.time.chrono.Chronology;
import java.time.temporal.TemporalQueries;
/*w ww .ja v  a  2s . c  om*/
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    Chronology s = y.query(TemporalQueries.chronology());
    System.out.println(s);

  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset