@Immutable
public final class TimeInterval
extends Object
implements Serializable
A time interval instance represents the time interval between two absolute times. It may be specified as either open or closed at each end.
To be valid, a time interval must not go backward.
Modifier and Type | Class and Description |
---|---|
static class |
TimeInterval.Builder
Time interval builder.
|
static class |
TimeInterval.InvalidIntervalException
Invalid interval exception.
|
Modifier and Type | Field and Description |
---|---|
static TimeInterval |
UNLIMITED
Unlimited time interval.
|
Modifier and Type | Method and Description |
---|---|
TimeInterval |
after(DateTime after)
Returns a clone with the after time set.
|
TimeInterval |
before(DateTime before)
Returns a clone with the before time set.
|
boolean |
contains(DateTime dateTime)
Asks if this interval contains a date and time.
|
boolean |
equals(Object other) |
Optional<DateTime> |
getAfter()
Gets the after time.
|
Optional<DateTime> |
getBefore()
Gets the before time.
|
DateTime |
getBeginning(boolean closed)
Gets the date-time at the beginning of this.
|
DateTime |
getEnd(boolean closed)
Gets the date-time at the end of this.
|
Optional<DateTime> |
getNotAfter()
Gets not after time.
|
Optional<DateTime> |
getNotBefore()
Gets not before time.
|
int |
hashCode() |
boolean |
isAfter(DateTime dateTime)
Asks if this interval is after a date and time.
|
boolean |
isBefore(DateTime dateTime)
Asks if this interval is before a date and time.
|
boolean |
isFromBeginningOfTime()
Asks if this time interval is from the beginning of time.
|
boolean |
isInstant()
Asks if this time interval is an instant.
|
boolean |
isToEndOfTime()
Asks if this time interval is to the end of time.
|
static TimeInterval.Builder |
newBuilder()
Returns a new builder.
|
TimeInterval |
notAfter(DateTime notAfter)
Returns a clone with the end set.
|
TimeInterval |
notBefore(DateTime notBefore)
Returns a clone with the beginning set.
|
String |
toString() |
TimeInterval |
trimmed(TimeInterval limits)
Returns a clone of this time interval trimmed to supplied limits.
|
public static final TimeInterval UNLIMITED
@Nonnull @CheckReturnValue public static TimeInterval.Builder newBuilder()
@Nonnull @CheckReturnValue public TimeInterval after(@Nonnull DateTime after)
after
- The after time.@Nonnull @CheckReturnValue public TimeInterval before(@Nonnull DateTime before)
before
- The before time.@CheckReturnValue public boolean contains(@Nonnull DateTime dateTime)
dateTime
- The date and time.public boolean equals(Object other)
equals
in class Object
@Nonnull @CheckReturnValue public Optional<DateTime> getAfter()
@Nonnull @CheckReturnValue public Optional<DateTime> getBefore()
@Nonnull @CheckReturnValue public DateTime getBeginning(boolean closed)
closed
- True for a closed limit.@Nonnull @CheckReturnValue public DateTime getEnd(boolean closed)
closed
- True for a closed limit.@Nonnull @CheckReturnValue public Optional<DateTime> getNotAfter()
@Nonnull @CheckReturnValue public Optional<DateTime> getNotBefore()
public int hashCode()
hashCode
in class Object
@CheckReturnValue public boolean isAfter(@Nonnull DateTime dateTime)
dateTime
- The date and time.@CheckReturnValue public boolean isBefore(@Nonnull DateTime dateTime)
dateTime
- The date and time.@CheckReturnValue public boolean isFromBeginningOfTime()
@CheckReturnValue public boolean isInstant()
@CheckReturnValue public boolean isToEndOfTime()
@Nonnull @CheckReturnValue public TimeInterval notAfter(@Nonnull DateTime notAfter)
notAfter
- The closed end of the interval.@Nonnull @CheckReturnValue public TimeInterval notBefore(@Nonnull DateTime notBefore)
notBefore
- The closed beginning of the interval.public String toString()
toString
in class Object
@Nonnull @CheckReturnValue public TimeInterval trimmed(@Nonnull TimeInterval limits)
limits
- The limits.Copyright © 2003-2019 Serge Brisson. All Rights Reserved.