public final class TimeFrame extends Object implements ITimeFrameSource
TimeFrame.
TimeFrames can be constructed by calling the valueOf static factory
methods valueOf(Time, Time) (yielding a TimeFrame between two absolute
times) and valueOf(Time, Duration) yielding a TimeFrame starting at an
absolute time and having a given length.
The start and end of a TimeFrame can be retrieved by calling getStart
and getEnd. Its duration can be retrieved by calling getDuration.
The contains(Time) method can be called to determine if a TimeFrame
contains a given point in time. The overlaps(TimeFrame) method can be called to
determine if two TimeFrames overlap.
The eachDay(TimeOfDay, TimeOfDay) will return a TimeFrameSource which
generates a TimeFrame using the two times of day. In other words, if the start is
3pm and the end is 4pm, the TimeFrameSource returned will yield 3-4pm on the day it
is called (each day).
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Time time)
Determines if this
TimeFrame contains a given point in time. |
static ITimeFrameSource |
eachDay(TimeOfDay startTimeOfDay,
TimeOfDay endTimeOfDay)
Creates an
ITimeFrameSource source for start and end TimeOfDays. |
boolean |
equals(Object obj) |
Duration |
getDuration()
Retrieves the
Duration of this TimeFrame. |
Time |
getEnd()
Retrieves the end
Time of this TimeFrame. |
Time |
getStart()
Retrieves the start
Time of this TimeFrame. |
TimeFrame |
getTimeFrame()
Implementation of
ITimeFrameSource that simply returns this
TimeFrame. |
int |
hashCode() |
boolean |
overlaps(TimeFrame timeframe)
Determines if two
TimeFrames overlap. |
String |
toString()
Converts this
TimeFrame to a String representation. |
static TimeFrame |
valueOf(Time start,
Duration duration)
Creates a
TimeFrame for a start Time and Duration. |
static TimeFrame |
valueOf(Time start,
Time end)
Creates a
TimeFrame for given start and end Times. |
public static ITimeFrameSource eachDay(TimeOfDay startTimeOfDay, TimeOfDay endTimeOfDay)
ITimeFrameSource source for start and end TimeOfDays.
For example, called with 3pm and 5pm as parameters, the TimeFrame source
returned would produce TimeFrame objects representing 3pm-5pm on whatever day it
is when the caller calls the TimeFrameSource interface.startTimeOfDay - the start TimeOfDay for this TimeFrame each dayendTimeOfDay - the end TimeOfDay for this TimeFrame each dayTimeFrameSource which will return the specified TimeFrame
each daypublic static TimeFrame valueOf(Time start, Duration duration)
TimeFrame for a start Time and Duration.start - the start Timeduration - the DurationTimeFrameIllegalArgumentException - thrown if start Time value is before end Time valuepublic static TimeFrame valueOf(Time start, Time end)
TimeFrame for given start and end Times.start - the start Timeend - the end TimeTimeFrameIllegalArgumentException - thrown if start Time value is before end Time valuepublic boolean contains(Time time)
TimeFrame contains a given point in time.time - the Time to checktrue if this TimeFrame contains the given timepublic Duration getDuration()
Duration of this TimeFrame.Duration of this TimeFramepublic Time getEnd()
Time of this TimeFrame.TimeFramepublic Time getStart()
Time of this TimeFrame.TimeFramepublic TimeFrame getTimeFrame()
ITimeFrameSource that simply returns this
TimeFrame.getTimeFrame in interface ITimeFrameSourceTimeFramepublic boolean overlaps(TimeFrame timeframe)
TimeFrames overlap.timeframe - the TimeFrame to testtrue if the given TimeFrame overlaps this oneCopyright © 2006–2021 Apache Software Foundation. All rights reserved.