{"id":37028650,"url":"https://github.com/state-machine-systems/mock-clock","last_synced_at":"2026-01-14T03:25:51.820Z","repository":{"id":57727275,"uuid":"47769587","full_name":"state-machine-systems/mock-clock","owner":"state-machine-systems","description":"A mock Clock implementation for Java 8","archived":false,"fork":false,"pushed_at":"2020-10-13T00:12:43.000Z","size":14,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T23:02:47.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/state-machine-systems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-10T15:15:00.000Z","updated_at":"2024-02-27T23:26:05.000Z","dependencies_parsed_at":"2022-09-26T20:22:03.210Z","dependency_job_id":null,"html_url":"https://github.com/state-machine-systems/mock-clock","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/state-machine-systems/mock-clock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fmock-clock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fmock-clock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fmock-clock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fmock-clock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/state-machine-systems","download_url":"https://codeload.github.com/state-machine-systems/mock-clock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/state-machine-systems%2Fmock-clock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T03:25:51.234Z","updated_at":"2026-01-14T03:25:51.808Z","avatar_url":"https://github.com/state-machine-systems.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Java 8's `Clock` class is a big step in the right direction for testability, but it's still a pain. You can\ntest using `Clock.fixed()` but that's immutable so you can't test how your code responds to the passage of time.\nYou can use a mocking library to stub the `instant()` and `getZone()` methods, but that's still awkward and indirect.\n\nThis library provides a mutable `MockClock` class that can be constructed as of a given date and time, then adjusted as\nneeded. Here's an example of how to use it:\n\n\n    import com.statemachinesystems.mockclock.MockClock;\n    import java.time.ZoneId;\n\n    MockClock clock = MockClock.at(2015, 12, 10, 11, 16, ZoneId.of(\"UTC\"));\n    ClassUnderTest testSubject = new ClassUnderTest(clock);\n\n    assertThat(testSubject.someMethod(), is(expectedValueAtStartTime));\n\n    clock.advanceBySeconds(30);\n\n    assertThat(testSubject.someMethod(), is(expectedValueAfter30Seconds));\n\nThis library is in the Maven Central repo, so just add the following chunk to your pom.xml (or the equivalent for Gradle/SBT/whatever):\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.statemachinesystems\u003c/groupId\u003e\n        \u003cartifactId\u003emock-clock\u003c/artifactId\u003e\n        \u003cversion\u003e1.0\u003c/version\u003e\n    \u003c/dependency\u003e\n\n\n\u0026copy; 2015 State Machine Systems Ltd. [Apache Licence, Version 2.0]( http://www.apache.org/licenses/LICENSE-2.0)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machine-systems%2Fmock-clock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstate-machine-systems%2Fmock-clock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstate-machine-systems%2Fmock-clock/lists"}