Example usage for java.time Instant query

List of usage examples for java.time Instant query

Introduction

In this page you can find the example usage for java.time Instant query.

Prototype

@SuppressWarnings("unchecked")
@Override
public <R> R query(TemporalQuery<R> query) 

Source Link

Document

Queries this instant using the specified query.

Usage

From source file:Main.java

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);// w  ww.ja v  a  2s .  c o m

}

From source file:Main.java

public static void main(String[] args) {
    Clock defaultClock = Clock.systemDefaultZone();

    Instant instant = Instant.now(defaultClock);

    TemporalQuery query = (TemporalAccessor x) -> x.isSupported(ChronoField.MILLI_OF_DAY);

    System.out.println(instant.query(query));
}