Skip to content

Latest commit

 

History

History
91 lines (47 loc) · 3.87 KB

OVERVIEW.md

File metadata and controls

91 lines (47 loc) · 3.87 KB

Code Overview

If you prefer Javadocs, they are available on javadoc.io:

Javadocs

Interfaces

An object that provides the current time since the Unix epoch, with nanosecond precision.

An object that can run a single Runnable task repeatedly at a steady rate.

An object that supplies values meant to represent the current wall-clock time.

A provider of unit suffixes for formatting Duration values of varying units.

Enums

Strategies for formatting Durations that have a remainder smaller than the smallest unit of time that will be shown.

Real Implementations

This object holds configuration information for a DurationFormatter instance.

This object will build a DurationFormat instance.

Factory methods for DurationFormat instances.

Formatter for a Duration value.

A simple implementation of a PeriodicRunner using a ScheduledExecutorService.

Instances of this class will run a single Runnable task repeatedly at a rate specified in terms of an interval.

Factory methods for UnitSuffixProvider instances that behave in ways that are appropriate for most locales.

Intentionally omitted:

These interfaces can trivially be implemented as a lambda in your calling code, so no library implementation is provided:

TimeSource

TimeSource t = ()->Instant.now();

CurrentNanosSource:

CurrentNanosSource c = ()->System.nanoTime();

Fake Implementations

This starts with a fixed number of nanoseconds since the epoch, and automatically increments the returned nanoseconds value by 1 each time currentTimeNanoPrecision is called. There is also an incrementTimeNanos method that lets a test simulate a delay of a specified number of nanoseconds.

This lets the caller set a Runnable task, start and stop it, and checks to make sure start and stop are called under sane conditions (start requires that a task has been set; stop requires that a task has been started). There is a runOnce method that tests can call to simulate the periodic timer firing and running the Runnable task.

This starts with a fixed number of millis since the epoch, and automatically advances the returned fake time by default (so each call to now will return a different Instant representing a slightly later point in time). The caller can also simulate a delay of a specified java.time.Duration.