public final class AdaptableDate extends Object
LocalDateTime
, allowing to be a static one,
or a relative one to the moment the resolveDateTime()
method is called.
AdaptableDate
can be resolved
mutliple times, without being a problem at all, it just can lead to different results.
AdaptableDate
with:
fromDateTime(java.time.LocalDateTime)
to have a static one, always resolved as the same given LocalDateTime
fromDate(java.time.LocalDate)
to have a static one, always resolved as the same given LocalDate
(at the start of the day)now()
to have one resolved as the current LocalDateTime
when resolveDateTime()
is calledfuture(long, java.time.temporal.TemporalUnit)
to have one resolved with the given amount of given TemporalUnit
added to the current LocalDateTime
when resolveDateTime()
is calledpast(long, java.time.temporal.TemporalUnit)
to have one resolved with the given amount of given TemporalUnit
subtracted to the current LocalDateTime
when resolveDateTime()
is calledModifier and Type | Class and Description |
---|---|
private static class |
AdaptableDate.AdaptableDateType |
private static class |
AdaptableDate.OffsetType |
Modifier and Type | Field and Description |
---|---|
private static AdaptableDate |
__NOW |
private long |
_relativeAmount |
private AdaptableDate.OffsetType |
_relativeOffsetType |
private TemporalUnit |
_relativeUnit |
private LocalDateTime |
_staticValue |
private AdaptableDate.AdaptableDateType |
_type |
Modifier | Constructor and Description |
---|---|
private |
AdaptableDate(AdaptableDate.OffsetType offsetType,
long amount,
TemporalUnit unit) |
private |
AdaptableDate(LocalDateTime date) |
Modifier and Type | Method and Description |
---|---|
static AdaptableDate |
fromDate(LocalDate date)
Gets a static
AdaptableDate , always resolved as the given LocalDate |
static AdaptableDate |
fromDateTime(LocalDateTime dateTime)
Gets a static
AdaptableDate , always resolved as the given LocalDateTime |
static AdaptableDate |
future(long amount,
TemporalUnit unit)
Gets an
AdaptableDate , resolved as the current LocalDateTime at the moment of the call ,
plus the given amount of the given TemporalUnit , so as to get a LocalDateTime in the future |
static AdaptableDate |
now()
|
static AdaptableDate |
past(long amount,
TemporalUnit unit)
Gets an
AdaptableDate , resolved as the current LocalDateTime at the moment of the call ,
minus the given amount of the given TemporalUnit , so as to get a LocalDateTime in the past |
LocalDate |
resolveDate()
Resolves this
AdaptableDate |
LocalDateTime |
resolveDateTime()
Resolves this
AdaptableDate |
String |
toString() |
private static final AdaptableDate __NOW
private final AdaptableDate.AdaptableDateType _type
private final LocalDateTime _staticValue
private final TemporalUnit _relativeUnit
private final long _relativeAmount
private final AdaptableDate.OffsetType _relativeOffsetType
private AdaptableDate(LocalDateTime date)
private AdaptableDate(AdaptableDate.OffsetType offsetType, long amount, TemporalUnit unit)
public static AdaptableDate fromDateTime(LocalDateTime dateTime)
AdaptableDate
, always resolved as the given LocalDateTime
dateTime
- The LocalDateTime
AdaptableDate
public static AdaptableDate fromDate(LocalDate date)
AdaptableDate
, always resolved as the given LocalDate
date
- The LocalDate
AdaptableDate
public static AdaptableDate now()
AdaptableDate
public static AdaptableDate past(long amount, TemporalUnit unit)
AdaptableDate
, resolved as the current LocalDateTime
at the moment of the call
,
minus the given amount of the given TemporalUnit
, so as to get a LocalDateTime
in the pastamount
- The amount to subtractunit
- The TemporalUnit
of the amount to subtractAdaptableDate
public static AdaptableDate future(long amount, TemporalUnit unit)
AdaptableDate
, resolved as the current LocalDateTime
at the moment of the call
,
plus the given amount of the given TemporalUnit
, so as to get a LocalDateTime
in the futureamount
- The amount to addunit
- The TemporalUnit
of the amount to addAdaptableDate
public LocalDateTime resolveDateTime()
AdaptableDate
LocalDateTime
public LocalDate resolveDate()
AdaptableDate
LocalDate