diff --git a/README.md b/README.md index b4b79ab..ee45699 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Test Coverage](https://api.codeclimate.com/v1/badges/6039371d2409365c76dc/test_coverage)](https://codeclimate.com/github/trickl/clock/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -A set of java.time.Clock implementations with more useful functionality. +A set of [java.time.Clock](https://docs.oracle.com/javase/8/docs/api/java/time/Clock.html) implementations with more useful functionality. * MutableClock - A version of FixedClock with a mutable time. * RelativeClock - An adjustable clock that time keeps using a relative clock, but can be stopped, started and run at variable speeds. @@ -35,5 +35,25 @@ mvn clean build ## Examples ### Mutable Clock - +``` + MutableClock mutableClock = MutableClock.at(clockStart); + Duration adjustment = Duration.ofMinutes(5); + mutableClock.advance(adjustment); + assertEquals(clockStart.plus(adjustment), mutableClock.instant()); +``` ### Relative Clock +``` + RelativeClock relativeClock = RelativeClock.standard() + .withReferenceClock(referenceClock); + + relativeClock.setSpeed(3); + referenceClock.advance(Duration.ofMinutes(3)); + relativeClock.setSpeed(5); + referenceClock.advance(Duration.ofMinutes(5)); + relativeClock.setSpeed(7); + referenceClock.advance(Duration.ofMinutes(7)); + + Instant expectedTime = referenceClockStart.plus(Duration.ofMinutes(83)); + + assertEquals(expectedTime, relativeClock.instant()); +```