Package net.fortuna.ical4j.model
Class TemporalComparator
- java.lang.Object
-
- net.fortuna.ical4j.model.TemporalComparator
-
- All Implemented Interfaces:
Comparator<Temporal>
public class TemporalComparator extends Object implements Comparator<Temporal>
The purpose of this comparator is to compare two temporals regardless of type. Some temporal types are not directly comparable, due to differences in supported units. For these cases we support hints to indicate how they should be compared. CompareTemporal
values based on a specifiedChronoUnit
.
-
-
Constructor Summary
Constructors Constructor Description TemporalComparator()
TemporalComparator(TemporalUnit defaultComparisonUnit)
TemporalComparator(TemporalUnit defaultComparisonUnit, ZoneId defaultZoneId)
TemporalComparator(ZoneId defaultZoneId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Instant o1, Instant o2)
int
compare(Instant o1, LocalDate o2)
int
compare(Instant o1, LocalDateTime o2)
int
compare(LocalDate o1, Instant o2)
int
compare(LocalDate o1, LocalDate o2)
int
compare(LocalDate o1, LocalDateTime o2)
int
compare(LocalDateTime o1, Instant o2)
int
compare(LocalDateTime o1, LocalDate o2)
int
compare(LocalDateTime o1, LocalDateTime o2)
int
compare(Temporal o1, Temporal o2)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
TemporalComparator
public TemporalComparator()
-
TemporalComparator
public TemporalComparator(TemporalUnit defaultComparisonUnit)
-
TemporalComparator
public TemporalComparator(ZoneId defaultZoneId)
-
TemporalComparator
public TemporalComparator(TemporalUnit defaultComparisonUnit, ZoneId defaultZoneId)
- Parameters:
defaultComparisonUnit
- the fallback comparison unit if all other temporal comparisons are not applicable.
-
-
Method Detail
-
compare
public int compare(Temporal o1, Temporal o2)
- Specified by:
compare
in interfaceComparator<Temporal>
-
compare
public int compare(LocalDateTime o1, LocalDateTime o2)
-
compare
public int compare(Instant o1, LocalDateTime o2)
-
compare
public int compare(LocalDateTime o1, Instant o2)
-
compare
public int compare(LocalDateTime o1, LocalDate o2)
-
compare
public int compare(LocalDate o1, LocalDateTime o2)
-
-