public class Calendar extends Object
Represents a calendar used in a project. How to create simple calendar from scratch. // create empty calendar Calendar calendar = new Calendar(); // adds default working days (8 working hours from 9:00 to 17:00) calendar.getDays().add(WeekDay.createDefaultWorkingDay(DayType.Monday)); calendar.getDays().add(WeekDay.createDefaultWorkingDay(DayType.Tuesday)); calendar.getDays().add(WeekDay.createDefaultWorkingDay(DayType.Wednesday)); // create new new working day WeekDay myWeekDay = new WeekDay(DayType.Thursday); // Sets working time. Only time part of DateTime is important WorkingTime wt1 = new WorkingTime(); wt1.setFromTime(new Date(1, 1, 1, 6, 0, 0)); wt1.setToTime(new Date(1, 1, 1, 12, 0, 0)); WorkingTime wt2 = new WorkingTime(); wt2.setFromTime(new Date(1, 1, 1, 14, 0, 0)); wt2.setToTime(new Date(1, 1, 1, 18, 0, 0)); myWeekDay.getWorkingTimes().add(wt1); myWeekDay.getWorkingTimes().add(wt2); myWeekDay.setDayWorking(true); calendar.getDays().add(myWeekDay); calendar.getDays().add(WeekDay.createDefaultWorkingDay(DayType.Friday)); // adds weekend calendar.getDays().add(new WeekDay(DayType.Saturday)); calendar.getDays().add(new WeekDay(DayType.Sunday)); Calendars are used to define standard working and non-working times. Projects must have one base calendar. Tasks and resources can have their own non-base calendars that are based on a base calendar.
Constructor and Description |
---|
Calendar(String name)
Initializes a new instance of the
Calendar class with the specified name. |
Modifier and Type | Method and Description |
---|---|
void |
delete()
Removes calendar from project.
|
boolean |
equals(Object obj)
Returns a value indicating whether this instance is equal to a specified object.
|
Calendar |
getBaseCalendar()
Gets the base calendar on which this calendar depends.
|
CalendarExceptionCollection |
getExceptions()
Gets CalendarExceptionCollection object.
|
Date |
getFinishDateByStartAndWork(Date start,
double work)
Calculates the date when the specified amount of work time will pass according to the calendar.
|
Date |
getFinishDateByStartAndWork(Date start,
Duration work)
Calculates the date when the specified amount of work time will pass according to the calendar.
|
String |
getName()
Gets the name of the calendar.
|
Date |
getNextWorkingDayStart(Date date)
Calculates next working day start from the date.
|
Project |
getParentProject()
Gets parent project for this calendar.
|
Date |
getPreviousWorkingDayEnd(Date date)
Calculates previous working date end from the specified date.
|
Date |
getStartDateFromFinishAndDuration(Date finish,
double duration)
Returns StartDate based on specified FinishDate and Duration.
|
Date |
getStartDateFromFinishAndDuration(Date finish,
Duration duration)
Returns StartDate based on specified FinishDate and Duration.
|
Date |
getTaskFinishDateFromDuration(Task task,
double duration)
Calculates the task finish date and time from its start date, split parts and the duration.
|
int |
getUid()
Gets the unique identifier of the calendar.
|
WeekDayCollection |
getWeekDays()
Gets WeekDaysCollection for this calendar.
|
double |
getWorkingHours(Date dt)
Returns amount of working hours at the date.
|
WorkUnit |
getWorkingHours(Date start,
Date finish)
Return working hours for the specified dates.
|
WorkingTimeCollection |
getWorkingTimes(Date dt)
Returns
WorkingTimeCollection of working times. |
WorkWeekCollection |
getWorkWeeks()
Gets WorkWeekCollections object.
|
int |
hashCode()
Returns a hash code for the instance of the
Calendar class. |
boolean |
isBaseCalendar()
Gets a value indicating whether the calendar is a base calendar.
|
boolean |
isBaselineCalendar()
Gets a value indicating whether the calendar is a baseline calendar.
|
boolean |
isDayWorking(Date dt)
Determines whether the day is working day.
|
static Calendar |
make24HourCalendar()
Creates 24Hours Calendar named "24 Hours".
|
static Calendar |
make24HourCalendar(Calendar calendar)
Makes a given Calendar to be a 24Hour Calendar.
|
static Calendar |
makeNightShiftCalendar()
Creates Night Shift Calendar named "Night shift".
|
static Calendar |
makeNightShiftCalendar(Calendar calendar)
Makes a given Calendar as Night Shift Calendar.
|
static Calendar |
makeStandardCalendar()
Creates default standard calendar.
|
static Calendar |
makeStandardCalendar(Calendar calendar)
Creates default standard calendar.
|
void |
setBaseCalendar(Calendar value)
Sets the base calendar on which this calendar depends.
|
void |
setBaselineCalendar(boolean value)
Sets a value indicating whether the calendar is a baseline calendar.
|
void |
setName(String value)
Sets the name of the calendar.
|
void |
setUid(int value)
Sets the unique identifier of the calendar.
|
public final void delete()
Removes calendar from project.
public boolean equals(Object obj)
Returns a value indicating whether this instance is equal to a specified object.
public final Calendar getBaseCalendar()
Gets the base calendar on which this calendar depends.
Only applicable if the calendar is not a base calendar.
Read/write Calendar
.
public final void setBaseCalendar(Calendar value)
Sets the base calendar on which this calendar depends.
Only applicable if the calendar is not a base calendar.
Read/write Calendar
.
value
- the base calendar on which this calendar depends.public final CalendarExceptionCollection getExceptions()
Gets CalendarExceptionCollection object.
The collection of exceptions that is associated with the calendar.
Read only CalendarExceptionCollection
instance.
public final Date getFinishDateByStartAndWork(Date start, Duration work)
Calculates the date when the specified amount of work time will pass according to the calendar.
start
- Start date.work
- Work duration.public final Date getFinishDateByStartAndWork(Date start, double work)
Calculates the date when the specified amount of work time will pass according to the calendar.
start
- Start date.work
- Work duration.public final String getName()
Gets the name of the calendar.
Read/write String
.
public final void setName(String value)
Sets the name of the calendar.
Read/write String
.
value
- the name of the calendar.public final Date getNextWorkingDayStart(Date date)
Calculates next working day start from the date.
date
- The date to get next working day start for.Date
.public final Project getParentProject()
public final Date getPreviousWorkingDayEnd(Date date)
Calculates previous working date end from the specified date.
public final Date getStartDateFromFinishAndDuration(Date finish, Duration duration)
Returns StartDate based on specified FinishDate and Duration.
finish
- The specified finish date.duration
- The specified work duration.public final Date getStartDateFromFinishAndDuration(Date finish, double duration)
Returns StartDate based on specified FinishDate and Duration.
finish
- The specified finish date.duration
- The specified work duration.public final Date getTaskFinishDateFromDuration(Task task, double duration)
Calculates the task finish date and time from its start date, split parts and the duration.
task
- The task to get finish date for.duration
- The task duration to split on.
public final int getUid()
Gets the unique identifier of the calendar.
Read/write int
.
public final void setUid(int value)
Sets the unique identifier of the calendar.
Read/write int
.
value
- the unique identifier of the calendar.public final WeekDayCollection getWeekDays()
Gets WeekDaysCollection for this calendar.
The collection of weekdays that defines the calendar.
Read only WeekDayCollection
.
public final WorkWeekCollection getWorkWeeks()
Gets WorkWeekCollections object.
The collection of work weeks that is associated with the calendar.
Read only WorkWeekCollection
instance
public final WorkUnit getWorkingHours(Date start, Date finish)
Return working hours for the specified dates.
start
- Start date.finish
- Finish date.public final double getWorkingHours(Date dt)
Returns amount of working hours at the date.
dt
- The date to get working hours for.public final WorkingTimeCollection getWorkingTimes(Date dt)
Returns WorkingTimeCollection
of working times.
dt
- The date to get working times for.WorkingTime
.public int hashCode()
Returns a hash code for the instance of the Calendar
class.
public final boolean isBaseCalendar()
Gets a value indicating whether the calendar is a base calendar.
Read-only boolean
.
public final boolean isBaselineCalendar()
Gets a value indicating whether the calendar is a baseline calendar.
Read/write boolean
.
public final void setBaselineCalendar(boolean value)
Sets a value indicating whether the calendar is a baseline calendar.
Read/write boolean
.
value
- a value indicating whether the calendar is a baseline calendar.public final boolean isDayWorking(Date dt)
Determines whether the day is working day.
dt
- The date to check day is working for.public static Calendar make24HourCalendar()
Creates 24Hours Calendar named "24 Hours". 24Hours Calendar is a Calendar in which every day of week is working with Round-the-clock working hours.
public static Calendar make24HourCalendar(Calendar calendar)
Makes a given Calendar to be a 24Hour Calendar. 24Hours Calendar is a Calendar in which every day of week is working with Round-the-clock working hours.
calendar
- Calendar to make 24 Hours Calendar from.public static Calendar makeNightShiftCalendar()
Creates Night Shift Calendar named "Night shift".
public static Calendar makeNightShiftCalendar(Calendar calendar)
Makes a given Calendar as Night Shift Calendar.
calendar
- Calendar to make Night Shift Calendar.public static Calendar makeStandardCalendar()
Creates default standard calendar.