Package com.iizix
Class TimeInterval
java.lang.Object
com.iizix.TimeInterval
Class holding a start and end time. The start time may be unset, or the end time. The time is a time value in milliseconds since the epoch in UMT.
- Author:
- Christopher Mindus
Field Summary
Method Summary
Modifier and TypeMethodDescriptionstatic TimeInterval
between
(long startTime, long endTime) Creates a new instance of the time interval with only a end time set.static TimeInterval
endingAt
(long endTime) Creates a new instance of the time interval with only a end time set.boolean
Checks for equality.int
hashCode()
Gets the hash code of the time interval.boolean
isIncluded
(long time) Verifies if the time is between included in the time interval.static TimeInterval
startingAt
(long startTime) Creates a new instance of the time interval with only a start time set.toString()
Get a string representation of the time interval.
Field Details
NO_INTERVALS
Empty array of time intervals.
Method Details
startingAt
Creates a new instance of the time interval with only a start time set.- Parameters:
startTime
- The starting time in milliseconds since the epoch in UMT.- Returns:
- A new instance of the time interval.
- Throws:
IllegalArgumentException
- If thestartTime
is zero or negative.
endingAt
Creates a new instance of the time interval with only a end time set.- Parameters:
endTime
- The end time in milliseconds since the epoch in UMT.- Returns:
- A new instance of the time interval.
- Throws:
IllegalArgumentException
- If theendTime
is zero or negative.
between
Creates a new instance of the time interval with only a end time set.- Parameters:
startTime
- The starting time in milliseconds since the epoch in UMT.endTime
- The end time in milliseconds since the epoch in UMT.- Returns:
- A new instance of the time interval.
- Throws:
IllegalArgumentException
- If thestartTime
is zero or negative,endTime
is zero or negative orstartTime
is larger or equal toendTime
.
isIncluded
public boolean isIncluded(long time) Verifies if the time is between included in the time interval.- Parameters:
time
- The time in milliseconds since the epoch in GMT.- Returns:
true
if the time is included,false
if not.
hashCode
public int hashCode()Gets the hash code of the time interval.equals
Checks for equality.toString
Get a string representation of the time interval.