Package org.ametys.core.util.date
Class AdaptableDate
java.lang.Object
org.ametys.core.util.date.AdaptableDate
This represents an advanced
A single instance of
You can get an
LocalDateTime, allowing to be a static one,
or a relative one to the moment the resolveDateTime() method is called.
A single instance of
AdaptableDate can be resolved mutliple times, without being a problem at all, it just can lead to different results.
You can get an
AdaptableDate with:
fromDateTime(java.time.LocalDateTime)to have a static one, always resolved as the same givenLocalDateTimefromDate(java.time.LocalDate)to have a static one, always resolved as the same givenLocalDate(at the start of the day)-
now()to have one resolved as the currentLocalDateTimewhenresolveDateTime()is called -
future(org.ametys.core.util.date.AdaptableDate.AdaptableDateType, long, java.time.temporal.TemporalUnit)to have one resolved with the given amount of givenTemporalUnitadded to the currentLocalDateTimewhenresolveDateTime()is called -
past(org.ametys.core.util.date.AdaptableDate.AdaptableDateType, long, java.time.temporal.TemporalUnit)to have one resolved with the given amount of givenTemporalUnitsubtracted to the currentLocalDateTimewhenresolveDateTime()is called
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWays available to resolve dates.static final recordInterval ofLocalDateTime -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic AdaptableDateGets a staticAdaptableDate, always resolved as the givenLocalDatestatic AdaptableDatefromDateTime(LocalDateTime dateTime) Gets a staticAdaptableDate, always resolved as the givenLocalDateTimestatic AdaptableDatefuture(AdaptableDate.AdaptableDateType type, long amount, TemporalUnit unit) Gets anAdaptableDate, resolved as the currentLocalDateTimeat the moment of thecall, plus the given amount of the givenTemporalUnit, so as to get aLocalDateTimein the futureinthashCode()static AdaptableDatenow()static AdaptableDatepast(AdaptableDate.AdaptableDateType type, long amount, TemporalUnit unit) Gets anAdaptableDate, resolved as the currentLocalDateTimeat the moment of thecall, minus the given amount of the givenTemporalUnit, so as to get aLocalDateTimein the pastResolves thisAdaptableDateResolves thisAdaptableDatestatic AdaptableDatetoday()Gets anAdaptableDate, resolved at the beggining of the current day at the moment of thecalltoString()
-
Method Details
-
fromDateTime
Gets a staticAdaptableDate, always resolved as the givenLocalDateTime- Parameters:
dateTime- TheLocalDateTime- Returns:
- The
AdaptableDate
-
fromDate
Gets a staticAdaptableDate, always resolved as the givenLocalDate- Parameters:
date- TheLocalDate- Returns:
- The
AdaptableDate
-
now
- Returns:
- The
AdaptableDate
-
today
Gets anAdaptableDate, resolved at the beggining of the current day at the moment of thecall- Returns:
- The
AdaptableDate
-
past
public static AdaptableDate past(AdaptableDate.AdaptableDateType type, long amount, TemporalUnit unit) Gets anAdaptableDate, resolved as the currentLocalDateTimeat the moment of thecall, minus the given amount of the givenTemporalUnit, so as to get aLocalDateTimein the past- Parameters:
type- the type of the offset to consider (relative to now or the beginning of the current day)amount- The amount to subtractunit- TheTemporalUnitof the amount to subtract- Returns:
- The
AdaptableDate
-
future
public static AdaptableDate future(AdaptableDate.AdaptableDateType type, long amount, TemporalUnit unit) Gets anAdaptableDate, resolved as the currentLocalDateTimeat the moment of thecall, plus the given amount of the givenTemporalUnit, so as to get aLocalDateTimein the future- Parameters:
type- the type of the offset to consider (relative to now or the beginning of the current day)amount- The amount to addunit- TheTemporalUnitof the amount to add- Returns:
- The
AdaptableDate
-
resolveDateTime
Resolves thisAdaptableDate- Returns:
- The resolved
LocalDateTime
-
resolveDate
Resolves thisAdaptableDate- Returns:
- The resolved
LocalDate
-
toString
-
hashCode
-
equals
-