Package org.somda.sdc.common.util
Class AnyDateTime
java.lang.Object
org.somda.sdc.common.util.AnyDateTime
Date-time object that supports local and offset time depending on construction parameters.
Required as both local and offset representation are supported by XML Schema DateTime.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAn alternative lambda to be executed. -
Method Summary
Modifier and TypeMethodDescriptionstatic AnyDateTimecreate(LocalDateTime local) Creates an instance with local date and time.static AnyDateTimecreate(OffsetDateTime offset) Creates an instance with offset date and time.doIfLocal(Consumer<LocalDateTime> consumer) Convenience function to be called if object was created with local date and time.doIfOffset(Consumer<OffsetDateTime> consumer) Convenience function to be called if object was created with offset date and time.booleanCompares two AnyDateTime objects on equality.Returns a offset date and time no matter if a local time was given on construction.forceOffset(ZoneOffset localOffset) Returns a offset date and time no matter if a local date and time was given on construction.getLocal()Gets the local date and time.Gets the offset date and time.inthashCode()toString()
-
Method Details
-
create
Creates an instance with local date and time.- Parameters:
local- the local date and time to set.- Returns:
- a new instance.
-
create
Creates an instance with offset date and time.- Parameters:
offset- the offset date and time to set.- Returns:
- a new instance.
-
getOffset
Gets the offset date and time.- Returns:
- the offset time or
Optional.empty()if local time was given on construction.
-
getLocal
Gets the local date and time.- Returns:
- the local date and time or
Optional.empty()if offset date and time was given on construction.
-
forceOffset
Returns a offset date and time no matter if a local time was given on construction.- Returns:
- the offset date and time given on construction or a offset date and time based on the local date and time and default-derived timezone.
-
forceOffset
Returns a offset date and time no matter if a local date and time was given on construction.- Parameters:
localOffset- the time zone offset to use in case this objects stores local time.- Returns:
- the offset time given on construction or a offset time based on the local time and given timezone.
-
doIfLocal
Convenience function to be called if object was created with local date and time.- Parameters:
consumer- the consumer for the local date and time.- Returns:
- an alternative call, i.e. in case offset date and time was given.
-
doIfOffset
Convenience function to be called if object was created with offset date and time.- Parameters:
consumer- the consumer for the offset date and time.- Returns:
- an alternative call, i.e. in case local date and time was given.
-
equals
Compares two AnyDateTime objects on equality. -
hashCode
public int hashCode() -
toString
-