Java Date Time - LocalTime query(TemporalQuery query) example








LocalTime query(TemporalQuery<R> query) queries this time 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.LocalTime;
import java.time.temporal.TemporalQueries;
//from   w  w  w . j a  v a2s .  c o  m
public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();
    LocalTime s = l.query(TemporalQueries.localTime());
    System.out.println(s);
  }
}

The code above generates the following result.