Package dev.nm.misc.datastructure.time
Class LocalDateTimeInterval
- java.lang.Object
-
- dev.nm.misc.datastructure.time.LocalDateTimeInterval
-
public final class LocalDateTimeInterval extends Object
Represents an interval between twoLocalDateTime
. Intervals are inclusive of the start time and exclusive of the end time. The end time is always greater than or equal to the start time.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(LocalDateTimeInterval other)
boolean
contains(LocalDateTime t)
Whether this time interval contains the given time.LocalDateTime
end()
boolean
equals(Object obj)
int
hashCode()
static LocalDateTimeInterval
of(LocalDateTime start, LocalDateTime end)
Creates an interval from a start and end time.static LocalDateTimeInterval
of(LocalDateTime start, Period period)
Creates an interval from a start time and a period.static LocalDateTimeInterval
of(Period period, LocalDateTime end)
Creates an interval from a period and an end time.boolean
overlaps(LocalDateTimeInterval other)
Whether this time interval overlaps with the given time interval.LocalDateTime
start()
String
toString()
-
-
-
Method Detail
-
of
public static LocalDateTimeInterval of(LocalDateTime start, LocalDateTime end)
Creates an interval from a start and end time.- Parameters:
start
- the start time of the intervalend
- the end time of the interval- Returns:
- the interval
-
of
public static LocalDateTimeInterval of(LocalDateTime start, Period period)
Creates an interval from a start time and a period.- Parameters:
start
- the start time of the intervalperiod
- the period of the interval- Returns:
- the interval
-
of
public static LocalDateTimeInterval of(Period period, LocalDateTime end)
Creates an interval from a period and an end time.- Parameters:
period
- the period of the intervalend
- the end time of the interval- Returns:
- the interval
-
start
public LocalDateTime start()
-
end
public LocalDateTime end()
-
contains
public boolean contains(LocalDateTime t)
Whether this time interval contains the given time.- Parameters:
t
- the time to test- Returns:
true
if this interval contains the given time
-
contains
public boolean contains(LocalDateTimeInterval other)
-
overlaps
public boolean overlaps(LocalDateTimeInterval other)
Whether this time interval overlaps with the given time interval.- Parameters:
other
- the interval to test- Returns:
true
if this interval overlaps with the given interval
-
-