Java TemporalQuery create

Description

Java TemporalQuery create

import java.time.LocalDate;
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalQuery;
import java.time.temporal.TemporalUnit;

public class Main {
  public static void main(String[] args) {
    // Get references of the precision and local date queries
    TemporalQuery<TemporalUnit> precisionQuery = TemporalQueries.precision();
    TemporalQuery<LocalDate> localDateQuery = TemporalQueries.localDate();

    // Query a LocalDate
    LocalDate ld = LocalDate.now();
    TemporalUnit precision = ld.query(precisionQuery);
    LocalDate queryDate = ld.query(localDateQuery);
    System.out.println("Precision of LocalDate: " + precision);
    System.out.println("LocalDate of LocalDate: " + queryDate);

  }//from www. j a v  a 2 s.  c  o  m
}



PreviousNext

Related