Interface ApiClock (2.57.0)

publicinterfaceApiClock

An interface for getting the current value of a high-resolution time source, in nanoseconds.

Clocks other thanNanoClock are typically used only for testing.

This interface is required in addition to Java 8's Clock, because nanoTime is required to compare values with io.grpc.CallOptions.getDeadlineNanoTime().

Methods

millisTime()

publicabstractlongmillisTime()

Returns the current value of this clock's high-resolution time source, in milliseconds.

Returns
TypeDescription
long

nanoTime()

publicabstractlongnanoTime()

Returns the current value of this clock's high-resolution time source, in nanoseconds.

Returns
TypeDescription
long

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-31 UTC.