Package it.tidalwave.util
Interface TimeProvider
- All Known Implementing Classes:
TimeProvider.DefaultTimeProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A provider of current time. It should be used by code requiring a timestamp, so it can be mocked during tests.
MockTimeProvider in module "Test Utilities" is a suitable mock for performing tests.- Since:
- 3.2-ALPHA-1 (was previously InstantProvider since 1.39)
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the current time.default LocalDateTimeReturns the current time.default ZonedDateTimeReturns the current time.default Instantget()Returns the current time.static TimeProviderReturns the default instance.
-
Field Details
-
Method Details
-
currentInstant
Returns the current time.- Returns:
- the current time as an
Instant - Since:
- 3.2-ALPHA-2
-
get
Returns the current time. This method is provided to implementSupplier<Instant>. -
currentZonedDateTime
Returns the current time.- Returns:
- the current time as a
ZonedDateTimein the default zone. - Since:
- 3.2-ALPHA-2
-
currentLocalDateTime
Returns the current time.- Returns:
- the current time as a
LocalDateTimein the default zone. - Since:
- 3.2-ALPHA-2
-
getInstance
Returns the default instance.- Returns:
- the default instance
- Since:
- 3.2-ALPHA-2
-