Java Date Time - OffsetTime query(TemporalQuery query) example








OffsetTime 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.OffsetTime;
import java.time.ZoneOffset;
import java.time.temporal.TemporalQueries;
/*from w  ww. j a  v  a2  s.c o m*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    ZoneOffset n = m.query(TemporalQueries.offset());
    System.out.println(n);

  }
}

The code above generates the following result.