Package it.tidalwave.util
Interface TimeProvider
- 
- All Superinterfaces:
- java.util.function.Supplier<java.time.Instant>
 - 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.
 
 @FunctionalInterface public interface TimeProvider extends java.util.function.Supplier<java.time.Instant>A provider of current time. It should be used by code requiring a timestamp, so it can be mocked during tests.MockTimeProviderin 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 SummaryNested Classes Modifier and Type Interface Description static classTimeProvider.DefaultTimeProvider
 - 
Field SummaryFields Modifier and Type Field Description static java.util.concurrent.atomic.AtomicReference<TimeProvider>__INSTANCE
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.time.InstantcurrentInstant()Returns the current time.default java.time.LocalDateTimecurrentLocalDateTime()Returns the current time.default java.time.ZonedDateTimecurrentZonedDateTime()Returns the current time.default java.time.Instantget()Returns the current time.static TimeProvidergetInstance()Returns the default instance.
 
- 
- 
- 
Field Detail- 
__INSTANCEstatic final java.util.concurrent.atomic.AtomicReference<TimeProvider> __INSTANCE 
 
- 
 - 
Method Detail- 
currentInstant@Nonnull java.time.Instant currentInstant() Returns the current time.- Returns:
- the current time as an Instant
- Since:
- 3.2-ALPHA-2
 
 - 
get@Nonnull default java.time.Instant get() Returns the current time. This method is provided to implementSupplier<Instant>.- Specified by:
- getin interface- java.util.function.Supplier<java.time.Instant>
- Returns:
- the current time as an Instant
- Since:
- 3.2-ALPHA-2
 
 - 
currentZonedDateTime@Nonnull default java.time.ZonedDateTime currentZonedDateTime() Returns the current time.- Returns:
- the current time as a ZonedDateTimein the default zone.
- Since:
- 3.2-ALPHA-2
 
 - 
currentLocalDateTime@Nonnull default java.time.LocalDateTime currentLocalDateTime() Returns the current time.- Returns:
- the current time as a LocalDateTimein the default zone.
- Since:
- 3.2-ALPHA-2
 
 - 
getInstance@Nonnull static TimeProvider getInstance() Returns the default instance.- Returns:
- the default instance
- Since:
- 3.2-ALPHA-2
 
 
- 
 
-