Package net.morimekta.testing.time
Class FakeClock
- java.lang.Object
-
- java.time.Clock
-
- net.morimekta.testing.time.FakeClock
-
public class FakeClock extends java.time.ClockFake clock implementation for testing.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFakeClock.TimeListener
-
Constructor Summary
Constructors Constructor Description FakeClock()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(FakeClock.TimeListener listener)static FakeClockforCurrentTimeMillis(long millis)java.time.ZoneIdgetZone()java.time.Instantinstant()voidremoveListener(FakeClock.TimeListener listener)voidtick(long tickMs)Tick the fake clock the given number of milliseconds.voidtick(long time, java.util.concurrent.TimeUnit unit)FakeClockwithZone(java.time.ZoneId zoneId)
-
-
-
Method Detail
-
forCurrentTimeMillis
public static FakeClock forCurrentTimeMillis(long millis)
-
tick
public void tick(long tickMs)
Tick the fake clock the given number of milliseconds.- Parameters:
tickMs- Milliseconds to move the clock.
-
tick
public void tick(long time, @Nonnull java.util.concurrent.TimeUnit unit)
-
addListener
public void addListener(@Nonnull FakeClock.TimeListener listener)
-
removeListener
public void removeListener(@Nonnull FakeClock.TimeListener listener)
-
getZone
@Nonnull public java.time.ZoneId getZone()
- Specified by:
getZonein classjava.time.Clock
-
withZone
@Nonnull public FakeClock withZone(java.time.ZoneId zoneId)
- Specified by:
withZonein classjava.time.Clock
-
instant
@Nonnull public java.time.Instant instant()
- Specified by:
instantin classjava.time.Clock
-
-