Java Date Time - Instant query(TemporalQuery query) example








Instant query(TemporalQuery<R> query) queries this instant 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.Instant;
import java.time.LocalDate;
import java.time.temporal.TemporalQueries;
//from  www  .  j a  v  a2  s  .com
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");

    LocalDate z = instant.query( TemporalQueries.localDate());
    System.out.println(z);
 
  }
}

The code above generates the following result.