Class TimeFactory
java.lang.Object
com.thanlinardos.spring_enterprise_library.time.TimeFactory
Factory class for obtaining the current date and time, as well as time zone information.
This class uses a TimeProvider to get the current date and time, allowing for easy testing and customization.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeUnitGets the accuracy of the date provider.static LocalDategetDate()Gets the current date.static LocalDateTimeGets the current date time.static ZoneOffsetGets current time zone.static ZoneIdGets current time zone.static InstantGets the current instant.static LocalDateGets the maximum date that can be used in the system.static LocalDateTimeGets the maximum date time that can be used in the system.static InstantGets the minimum instant that can be used in the system.static LocalDateGets the minimum date that can be used in the system.static LocalDateTimeGets the minimum date time that can be used in the system.static InstantGets the minimum instant that can be used in the system.
-
Constructor Details
-
TimeFactory
Constructor for TimeFactory.- Parameters:
timeProvider- the TimeProvider to use for getting the current date and time.
-
-
Method Details
-
getAccuracy
Gets the accuracy of the date provider.- Returns:
- the accuracy of the date provider.
-
getDate
-
getDateTime
Gets the current date time.- Returns:
- the current date time.
-
getInstant
-
getMaxDate
Gets the maximum date that can be used in the system.- Returns:
- the maximum date that can be used in the system.
-
getMinDate
Gets the minimum date that can be used in the system.- Returns:
- the minimum date that can be used in the system.
-
getMaxDateTime
Gets the maximum date time that can be used in the system.- Returns:
- the maximum date time that can be used in the system.
-
getMinDateTime
Gets the minimum date time that can be used in the system.- Returns:
- the minimum date time that can be used in the system.
-
getMaxInstant
Gets the minimum instant that can be used in the system.- Returns:
- the minimum instant that can be used in the system.
-
getMinInstant
Gets the minimum instant that can be used in the system.- Returns:
- the minimum instant that can be used in the system.
-
getDefaultZoneId
Gets current time zone.- Returns:
- the current time zone as a ZoneId object.
-
getDefaultZone
Gets current time zone.- Returns:
- the current time zone as a ZoneOffset object.
-