Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeProvider that can be instantiated by passing a Clock instance #28

Open
mmondino opened this issue Mar 1, 2020 · 1 comment
Open
Labels
enhancement New feature or request question Further information is requested

Comments

@mmondino
Copy link

mmondino commented Mar 1, 2020

It would be interesting to have a timeprovider that can be instantiated by passing a clock instance as a parameter.

This would be useful for testing and when working with instances of Clock

    private class ClockTimeProvider implements TimeProvider {

        private Clock clock;

        public ClockTimeProvider(Clock clock) {

            this.clock = clock;
        }

        @Override
        public long getTime() throws TimeProviderException {

            return Instant.now(this.clock).getEpochSecond();
        }
    }
@samdjstevens
Copy link
Owner

Thanks for the suggestion - I can see the use that this could have in testing, but I'm wondering if a user would not just mock a TimeProvider in this case? Could you elabroate more on the non testing use case?

@samdjstevens samdjstevens added question Further information is requested enhancement New feature or request labels Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants