Skip to content

Latest commit

 

History

History
 
 

time4k

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Time4k

Download .github/workflows/build.yaml

GitHub license codebeat badge

A simple replacement for the Java clock and scheduler.

Installation

In Gradle, install the ForkHandles BOM and then this module in the dependency block:

implementation(platform("dev.forkhandles:forkhandles-bom:X.Y.Z"))
implementation("dev.forkhandles:time4k")

Motivation

The Java Clock is an abstract class, which is a pain. Time4k represents the clock as a simple typealias:

typealias TimeSource = () -> Instant

The library also provides a DeterministicScheduler which is a drop-in test replacement for using a ScheduledExecutorService. You can control time and make the scheduler move forward in a controlled manner.