DayOfWeek query(TemporalQuery query) example

Description

DayOfWeek query(TemporalQuery<R> query) queries this day-of-week 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.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalQuery;
import java.time.temporal.TemporalUnit;
// w  ww  .  ja v a2 s . c  o m
public class Main {
  public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    
    TemporalQuery<TemporalUnit> localDateQuery = TemporalQueries.precision();
    
    
    System.out.println(dayOfWeek.query(localDateQuery));
  }
}

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