|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.dlsc.flexgantt.model.TimeSpan
public class TimeSpan
An implementation of the ITimeSpan
interface.
Field Summary | |
---|---|
static ITimeSpan |
DEFAULT_TIME_SPAN
Stores a default time span instance, where the start time is the current system time and the end time is the current system time plus one year. |
static TimeSpan |
UNDEFINED
An undefined time span, which gets used in various algorithms to express that no valid time span has been calculated, yet. |
Constructor Summary | |
---|---|
TimeSpan()
Constructs a new time span where the start and end time are equal to zero. |
|
TimeSpan(java.util.Calendar time)
Constructs a new time span where the start and end times are equal to the milliseconds of the given calendar object. |
|
TimeSpan(java.util.Calendar start,
java.util.Calendar end)
Constructs a new time span where the start and end times are based on the given calendar objects. |
|
TimeSpan(java.util.Date date)
Constructs a new time span where the start and end times are equal to the give date. |
|
TimeSpan(java.util.Date start,
java.util.Date end)
Constructs a new time span with the given start and end dates. |
|
TimeSpan(int year,
int month,
int date)
Constructs a new time point for the given year, month and date. |
|
TimeSpan(int startYear,
int startMonth,
int startDate,
int endYear,
int endMonth,
int endDate)
Constructs a new time span for the given year, month and date. |
|
TimeSpan(ITimeSpan span)
Constructs a new time span based on an already existing time span. |
|
TimeSpan(long time)
Constructs a new time span where the start time and the end time are both equal to given time. |
|
TimeSpan(long start,
long end)
Constructs a new time span with the given start and end. |
Method Summary | |
---|---|
int |
compareTo(ITimeSpan span)
|
boolean |
contains(ITimeSpan span)
Checks whether the time span contains the given time span. |
boolean |
endsAfter(ITimeSpan span)
Checks whether the given time span ends after this time span. |
boolean |
endsBefore(ITimeSpan span)
Checks whether the given time span ends before this time span. |
boolean |
equalDuration(ITimeSpan span)
Checks whether the given time span has exactly the same duration as this time span. |
boolean |
equals(ITimeSpan span)
Two time spans are considered equal if their start times and their end times are identical. |
boolean |
equals(java.lang.Object o)
|
long |
getDuration()
Calculates the total duration of this time span. |
java.util.Calendar |
getEndCalendar()
Returns a new calendar object based on the current end time. |
java.util.Date |
getEndDate()
Returns a new date object based on the current end time. |
long |
getEndTime()
Returns the time span's end time. |
java.util.Calendar |
getStartCalendar()
Returns a new calendar object based on the current start time. |
java.util.Date |
getStartDate()
Returns a new date object based on the current start time. |
long |
getStartTime()
Returns the time span's start time. |
boolean |
intersects(ITimeSpan span)
Checks whether the given time span intersects with this time span. |
boolean |
isActivity()
Determines whether this time span represents an activity. |
boolean |
isEvent()
Determines whether this time span represents an event. |
boolean |
isUndefined()
Checks whether this time span is undefined. |
TimeSpan |
move(long delta)
Constructs a new time span based on this span where the given (delta) milliseconds are added to (or subtracted from if negative) the start and end time of this time span. |
boolean |
startsAfter(ITimeSpan span)
Checks whether the given time span starts after this time span. |
boolean |
startsBefore(ITimeSpan span)
Checks whether the given time span starts before this time span. |
java.lang.String |
toString()
|
java.lang.String |
toString(java.text.DateFormat format)
Returns a compact string representation of the time span. |
ITimeSpan |
union(ITimeSpan span)
The union of two time spans is a new time span, where the start time of the new span is the minimum start time and the end time is the maximum end time of the two spans. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final TimeSpan UNDEFINED
public static final ITimeSpan DEFAULT_TIME_SPAN
Constructor Detail |
---|
public TimeSpan(long start, long end)
start
- the start time of the time spanend
- the end time of the time spanpublic TimeSpan(long time)
time
- the start and end time of the time spanpublic TimeSpan(ITimeSpan span)
span
- the original time spanpublic TimeSpan(java.util.Date start, java.util.Date end)
start
- the start time of the time spanend
- the end time of the time spanDate.getTime()
public TimeSpan(java.util.Date date)
date
- the start and end date of the time spanDate.getTime()
public TimeSpan(java.util.Calendar start, java.util.Calendar end)
start
- the start time of the time spanend
- the end time of the time spanCalendar.getTimeInMillis()
public TimeSpan(java.util.Calendar time)
time
- the start and end time of the time spanCalendar.getTimeInMillis()
public TimeSpan(int year, int month, int date)
year
- the year of the time pointmonth
- the month of the time point (note: months start with 0,
January = 0)date
- the day of the time pointpublic TimeSpan(int startYear, int startMonth, int startDate, int endYear, int endMonth, int endDate)
startYear
- the start year of the time spanstartMonth
- the start month of the time span (note: months start with 0,
January = 0)startDate
- the start date of the time spanendYear
- the end year of the time spanendMonth
- the end month of the time span (note: months start with 0,
January = 0)endDate
- the end date of the time spanpublic TimeSpan()
Method Detail |
---|
public long getStartTime()
ITimeSpan
getStartTime
in interface ITimeSpan
ITimeSpan.getEndTime()
public java.util.Date getStartDate()
Date
public java.util.Calendar getStartCalendar()
Calendar
getStartTime()
,
getStartDate()
public long getEndTime()
ITimeSpan
getEndTime
in interface ITimeSpan
ITimeSpan.getStartTime()
public java.util.Date getEndDate()
Date
getEndTime()
,
getEndCalendar()
public java.util.Calendar getEndCalendar()
Calendar
getEndTime()
,
getEndDate()
public int compareTo(ITimeSpan span)
compareTo
in interface java.lang.Comparable<ITimeSpan>
public boolean contains(ITimeSpan span)
ITimeSpan
contains
in interface ITimeSpan
span
- the time span to test for containment
ITimeSpan.intersects(ITimeSpan)
public boolean endsAfter(ITimeSpan span)
ITimeSpan
endsAfter
in interface ITimeSpan
span
- the time span to test
ITimeSpan.endsBefore(ITimeSpan)
public boolean endsBefore(ITimeSpan span)
ITimeSpan
endsBefore
in interface ITimeSpan
span
- the time span to test
ITimeSpan.endsAfter(ITimeSpan)
public boolean equalDuration(ITimeSpan span)
ITimeSpan
equalDuration
in interface ITimeSpan
span
- the time span to test
ITimeSpan.getDuration()
public long getDuration()
ITimeSpan
getDuration
in interface ITimeSpan
ITimeSpan.equalDuration(ITimeSpan)
public boolean intersects(ITimeSpan span)
ITimeSpan
intersects
in interface ITimeSpan
span
- the time span to test for intersection
ITimeSpan.contains(ITimeSpan)
public boolean isActivity()
ITimeSpan
isActivity
in interface ITimeSpan
ITimeSpan.isEvent()
public boolean isEvent()
ITimeSpan
isEvent
in interface ITimeSpan
ITimeSpan.isEvent()
public TimeSpan move(long delta)
ITimeSpan
move
in interface ITimeSpan
delta
- the amount of milliseconds to add to or subtract from the new
time span's start and end time
public boolean startsAfter(ITimeSpan span)
ITimeSpan
startsAfter
in interface ITimeSpan
span
- the time span to test
ITimeSpan.startsBefore(ITimeSpan)
public boolean startsBefore(ITimeSpan span)
ITimeSpan
startsBefore
in interface ITimeSpan
span
- the time span to test
ITimeSpan.startsAfter(ITimeSpan)
public ITimeSpan union(ITimeSpan span)
ITimeSpan
ITimeSpan.isUndefined()
). If only one
of the spans is undefined then the other span becomes the result of the
union operation. If both of them are undefined then the result will be
undefined, too.
union
in interface ITimeSpan
span
- the second time span for the union
public boolean isUndefined()
ITimeSpan
ITimeSpan.union(ITimeSpan)
first checks
whether the span on which the method gets called is undefined. If so and
the given second time span is not undefined then the result of the union
operation will be a copy of the second span).
isUndefined
in interface ITimeSpan
public boolean equals(ITimeSpan span)
ITimeSpan
equals
in interface ITimeSpan
span
- the time span to test
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.text.DateFormat format)
ITimeSpan
toString
in interface ITimeSpan
format
- the formatter used to create a date string
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |