Package net.vleo.timel.time
Class Interval
- java.lang.Object
-
- net.vleo.timel.time.Interval
-
- All Implemented Interfaces:
Serializable
public final class Interval extends Object implements Serializable
An immutable class that represents an interval.- Author:
- Andrea Leofreddi
- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description boolean
contains(long instant)
Test if this interval contains the given instant.boolean
contains(Interval interval)
Test if this interval contains the given interval.boolean
isAfter(long instant)
boolean
isAfter(Interval interval)
boolean
isBefore(long instant)
boolean
isBefore(Interval interval)
static Interval
of(long start, long end)
Retrieve an interval in between start and end expressed as millis from epoch.static Interval
of(Instant start, Instant end)
Retrieve an interval in between start and end instants.Interval
overlap(Interval interval)
boolean
overlaps(Interval interval)
long
toDurationMillis()
String
toString()
-
-
-
Method Detail
-
of
public static Interval of(Instant start, Instant end)
Retrieve an interval in between start and end instants.- Parameters:
start
- Start instantend
- End instant- Returns:
- Interval [start, end)
-
of
public static Interval of(long start, long end)
Retrieve an interval in between start and end expressed as millis from epoch.- Parameters:
start
- Start time (epoch millis)end
- End time (epoch millis)- Returns:
- Interval [start, end)
-
contains
public boolean contains(long instant)
Test if this interval contains the given instant.- Parameters:
instant
- Instant (epoch millis)- Returns:
- Test result
-
contains
public boolean contains(Interval interval)
Test if this interval contains the given interval.- Parameters:
interval
- Interval to test- Returns:
- Test result
-
isAfter
public boolean isAfter(long instant)
-
isAfter
public boolean isAfter(Interval interval)
-
isBefore
public boolean isBefore(long instant)
-
isBefore
public boolean isBefore(Interval interval)
-
overlaps
public boolean overlaps(Interval interval)
-
toDurationMillis
public long toDurationMillis()
-
-