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
FieldsMethod Summary
Modifier and TypeMethodDescriptionstatic TimeIntervalbetween(long startTime, long endTime) Creates a new instance of the time interval with only a end time set.static TimeIntervalendingAt(long endTime) Creates a new instance of the time interval with only a end time set.booleanChecks for equality.inthashCode()Gets the hash code of the time interval.booleanisIncluded(long time) Verifies if the time is between included in the time interval.static TimeIntervalstartingAt(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 thestartTimeis 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 theendTimeis 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 thestartTimeis zero or negative,endTimeis zero or negative orstartTimeis 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:
trueif the time is included,falseif 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.