Package org.apache.juneau.commons.time
Class TimeProvider
java.lang.Object
org.apache.juneau.commons.time.TimeProvider
Provides access to system time and timezone information.
This class abstracts time-related operations to allow for easier testing and customization. By default, it delegates to the system's time and timezone, but can be extended or replaced for testing purposes (e.g., using a custom implementation that provides fixed times).
Usage:
See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeProviderThe default instance that uses the system's time and timezone. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the system default timezone.now()Returns the current date and time in the system default timezone.Returns the current date and time in the specified timezone.
-
Field Details
-
INSTANCE
The default instance that uses the system's time and timezone.
-
-
Constructor Details
-
TimeProvider
public TimeProvider()
-
-
Method Details
-
getSystemDefaultZoneId
Returns the system default timezone.- Returns:
- The system default
ZoneId.
-
now
Returns the current date and time in the system default timezone.- Returns:
- The current
ZonedDateTimein the system default timezone.
-
now
Returns the current date and time in the specified timezone.- Parameters:
zoneId- The timezone to use. Must not benull .- Returns:
- The current
ZonedDateTimein the specified timezone.
-