Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Have a look at this method on Java's Instant class for an example.

https://docs.oracle.com/javase/8/docs/api/java/time/Instant....

Code under test creates Instant, so long as it uses the Clock you've passed in, you'll control how it determines when now() is.

You've got several built-in testing clocks like this one[1], but can also implement your own.

[1]: https://docs.oracle.com/javase/8/docs/api/java/time/Clock.ht...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: