FakeClock

open class FakeClock @JvmOverloads constructor(epochMillis: Long = Instant.parse("2018-01-01T00:00:00Z").toEpochMilli(), zone: ZoneId = ZoneId.of("UTC")) : Clock

Controllable clock for testing.

Constructors

Link copied to clipboard
constructor(epochMillis: Long = Instant.parse("2018-01-01T00:00:00Z").toEpochMilli(), zone: ZoneId = ZoneId.of("UTC"))

Functions

Link copied to clipboard
fun add(d: Duration): Long

Advance the clock by specified Duration.

fun add(p: Period): Long

Advance the clock by the specified Period. Note that unlike adding a Duration the exact amount that is added to the clock will depend on its current time and timezone. Not all days, months or years have the same length. See the documentation for Period.

fun add(n: Long, unit: TimeUnit): Long

Advance the clock by specified amount n of TimeUnit.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun getZone(): ZoneId
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun instant(): Instant
Link copied to clipboard
open override fun millis(): Long
Link copied to clipboard
fun setNow(instant: Instant)

Set the clock to the specified Instant.

Link copied to clipboard
open override fun withZone(zone: ZoneId): Clock