public final class TimeSpan extends Object implements Comparable<TimeSpan>, Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
TimeSpan.Started
A "started" time span, which works as a simple builder
for a complete
TimeSpan, using the concluding methods
TimeSpan.Started.until(Instant) or TimeSpan.Started.lasting(Duration) |
| Modifier and Type | Field and Description |
|---|---|
Duration |
duration |
static TimeSpan |
EMPTY_FAR_PAST |
Instant |
end |
Instant |
start |
| Modifier and Type | Method and Description |
|---|---|
Stream<TimeSpan> |
collapse(TimeSpan other)
Collapse to one or two spans.
|
int |
compareTo(TimeSpan other) |
boolean |
covers(TimeSpan other)
Check if the given TimeSpan is completly covered by this.
|
boolean |
equals(Object o) |
static TimeSpan.Started |
from(Instant start)
Start constructing a new
TimeSpan starting at the given Instant. |
int |
hashCode() |
boolean |
includes(Instant instant)
Check if an
Instant is part of this time span. |
Optional<TimeSpan> |
intersection(TimeSpan other)
Give the intersection (the overlapping part) of this
and the given
TimeSpan, or Optional.empty()
if they do not overlap. |
String |
toString() |
public static final TimeSpan EMPTY_FAR_PAST
public final Instant start
public final Instant end
public final Duration duration
public static TimeSpan.Started from(Instant start)
TimeSpan starting at the given Instant.
Use the returned TimeSpan.Started.until(Instant) or
TimeSpan.Started.lasting(Duration) to set the end.start - The start instant of the new TimeSpan.TimeSpan.Startedpublic Stream<TimeSpan> collapse(TimeSpan other)
TimeSpan overlaps
with this, they are merged together to a new TimeSpan instance which covers
the effective duration of the two spans. If the given TimeSpan does
not overlap with this, the two spans are returned in chronological order,
the earlier one placed first.other - The other TimeSpan to collapse this with.public Optional<TimeSpan> intersection(TimeSpan other)
TimeSpan, or Optional.empty()
if they do not overlap.public boolean includes(Instant instant)
Instant is part of this time span. Includes start
instant and excludes end instant of this time span.true if the given instant is part of this time span,
false otherwise.public boolean covers(TimeSpan other)
true if the given TimeSpan is covered by this,
false otherwise.public int compareTo(TimeSpan other)
compareTo in interface Comparable<TimeSpan>Copyright © 2018 Digipost. All rights reserved.