public class TemporalAccessorUtils extends Object
TemporalAccessor
Modifier and Type | Field and Description |
---|---|
static ZoneId |
UTC_ZONE_ID |
Constructor and Description |
---|
TemporalAccessorUtils() |
Modifier and Type | Method and Description |
---|---|
static Optional<TemporalAccessor> |
bestResolution(TemporalAccessor ta1,
TemporalAccessor ta2)
The idea of "best resolution" TemporalAccessor is to get the TemporalAccessor that offers more resolution than
the other, but they must NOT contradict.
|
static TemporalAccessor |
limitToResolution(TemporalAccessor ta,
int requiredResolution) |
static Temporal |
limitToResolution(Temporal ta,
int requiredResolution) |
static Optional<TemporalAccessor> |
nonConflictingDateParts(TemporalAccessor ta1,
TemporalAccessor ta2,
TemporalAccessor ta3)
The idea of "non-conflicting date parts" TemporalAccessor is to get as much of year, then month, then day as possible,
ignoring null and stopping once there is a contradiction.
|
static int |
resolution(TemporalAccessor ta)
Returns the resolution of the TemporalAccessor: year=1, month=2, day=3.
|
static int |
resolutionToSeconds(TemporalAccessor ta)
Returns the resolution of the TemporalAccessor: year=1, month=2, day=3, hour=4, minutes=5, seconds=6.
|
static Optional<TemporalAccessor> |
resolveAmbiguousDates(TemporalAccessor reliableTa,
List<TemporalAccessor> dodgyTas)
Returns a date from the list of dodgyTas which matches the reliableTa
|
static boolean |
sameDate(TemporalAccessor ta1,
TemporalAccessor ta2)
Given two TemporalAccessor with at least date resolution, this method checks if they represent the same
date.
|
static boolean |
sameOrContained(TemporalAccessor ta1,
TemporalAccessor ta2)
Given two TemporalAccessor with possibly different resolutions, this method checks if they represent the same
date, or if one is contained within the other.
|
static boolean |
sameOrContainedOrNull(TemporalAccessor ta1,
TemporalAccessor ta2)
Given two TemporalAccessor with possibly different resolutions, this method checks if they represent the same
date, or if one is contained within the other.
|
static TemporalAccessor |
stripOffsetOrZone(TemporalAccessor temporalAccessor,
boolean ignoreOffset)
Removes any time zone, optionally adjusting the time using the zone offset first.
|
static Date |
toDate(TemporalAccessor temporalAccessor)
Transform a
TemporalAccessor to a Date . |
static Date |
toDate(TemporalAccessor temporalAccessor,
boolean ignoreOffset)
Transform a
TemporalAccessor to a Date , rounding a partial date/time to the start
of the period. |
static LocalDateTime |
toEarliestLocalDateTime(TemporalAccessor temporalAccessor,
boolean ignoreOffset)
Transform a
TemporalAccessor to a LocalDateTime , rounding a partial date/time to the
start of the period. |
static LocalDateTime |
toLatestLocalDateTime(TemporalAccessor temporalAccessor,
boolean ignoreOffset)
Transform a
TemporalAccessor to a LocalDateTime , rounding a partial date/time to the
end of the period. |
static boolean |
withinRange(TemporalAccessor lowerBound,
TemporalAccessor upperBound,
TemporalAccessor queryTa)
Given two TemporalAccessor with at least day resolution (representing the bounds), and another TemporalAccessor
of day resolution, this method checks if the bounds contain the third argument.
|
public static ZoneId UTC_ZONE_ID
public TemporalAccessorUtils()
public static Date toDate(TemporalAccessor temporalAccessor)
TemporalAccessor
to a Date
.
If the provided TemporalAccessor
contains offset(timezone) information it will be used.
See toDate(TemporalAccessor, boolean)
for more details.public static Date toDate(TemporalAccessor temporalAccessor, boolean ignoreOffset)
TemporalAccessor
to a Date
, rounding a partial date/time to the start
of the period.
For YearMonth
, the Date
will represent the first day of the month.
For Year
, the Date
will represent the first day of January.
Remember that a Date
object will always display the date in the current timezone.ignoreOffset
- in case offset information is available in the provided TemporalAccessor
, should it
be used ?public static TemporalAccessor stripOffsetOrZone(TemporalAccessor temporalAccessor, boolean ignoreOffset)
public static LocalDateTime toEarliestLocalDateTime(TemporalAccessor temporalAccessor, boolean ignoreOffset)
TemporalAccessor
to a LocalDateTime
, rounding a partial date/time to the
start of the period.temporalAccessor
- ignoreOffset
- in case offset information is available in the provided TemporalAccessor
, should it
be used ?public static LocalDateTime toLatestLocalDateTime(TemporalAccessor temporalAccessor, boolean ignoreOffset)
TemporalAccessor
to a LocalDateTime
, rounding a partial date/time to the
end of the period.
1990 will be 1990-12-31,
1996-02 will be 1996-02-29temporalAccessor
- ignoreOffset
- in case offset information is available in the provided TemporalAccessor
, should it
be used ?public static Optional<TemporalAccessor> bestResolution(@Nullable TemporalAccessor ta1, @Nullable TemporalAccessor ta2)
public static TemporalAccessor limitToResolution(TemporalAccessor ta, int requiredResolution)
public static Temporal limitToResolution(Temporal ta, int requiredResolution)
public static Optional<TemporalAccessor> nonConflictingDateParts(@Nullable TemporalAccessor ta1, @Nullable TemporalAccessor ta2, @Nullable TemporalAccessor ta3)
public static boolean sameOrContained(@Nullable TemporalAccessor ta1, @Nullable TemporalAccessor ta2)
public static boolean sameOrContainedOrNull(@Nullable TemporalAccessor ta1, @Nullable TemporalAccessor ta2)
public static boolean sameDate(@Nullable TemporalAccessor ta1, @Nullable TemporalAccessor ta2)
public static boolean withinRange(@Nullable TemporalAccessor lowerBound, @Nullable TemporalAccessor upperBound, @Nullable TemporalAccessor queryTa)
public static Optional<TemporalAccessor> resolveAmbiguousDates(TemporalAccessor reliableTa, List<TemporalAccessor> dodgyTas)
public static int resolution(TemporalAccessor ta)
public static int resolutionToSeconds(TemporalAccessor ta)
Copyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.