com.aspose.tasks

Interfaces

Classes

Exceptions

com.aspose.tasks

Class Calendar



  • 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 Detail

      • Calendar

        public Calendar(String name)

        Initializes a new instance of the Calendar class with the specified name.

        Parameters:
        name - The name of the created calendar.
    • Method Detail

      • getName

        public String getName()

        Returns the name of the calendar. Read/write String.

        Returns:
        calendar name.
      • setName

        public void setName(String value)

        Sets the name of the calendar. Read/write String.

        Parameters:
        value - calendar name.
      • getUid

        public int getUid()

        The unique identifier of the calendar. /**

        Returns the unique identifier of the calendar. Read/write int.

        Returns:
        calendar UID.
      • setUid

        public void setUid(int value)

        Sets the unique identifier of the calendar. Read/write int.

        Parameters:
        value - calendar UID.
      • getWeekDays

        public WeekDayCollection getWeekDays()

        Returns WeekDaysCollection for this calendar. The collection of weekdays that defines the calendar. Read only WeekDayCollection.

        Returns:
        The collection of weekdays that defines the calendar.
      • getExceptions

        public CalendarExceptionCollection getExceptions()

        Returns CalendarExceptionCollection object. The collection of exceptions that is associated with the calendar. Read only CalendarExceptionCollection instance.

        Returns:
        CalendarExceptionCollection object which represents a collection of exceptions associated with the calendar..
      • getWorkWeeks

        public WorkWeekCollection getWorkWeeks()

        Returns WorkWeekCollections object. The collection of work weeks that is associated with the calendar. Read only WorkWeekCollection instance

        Returns:
        an instance of the WorkWeekCollections class for this calendar.
      • isBaseCalendar

        public boolean isBaseCalendar()

        Determines whether the calendar is a base calendar. Read-only boolean.

        Returns:
        true if a calendar is a base calendar.
      • getBaseCalendar

        public Calendar getBaseCalendar()

        Returns the base calendar on which this calendar depends. Only applicable if the calendar is not a base calendar. Read/write com.aspose.tasks.Calendar.

        Returns:
        base calendar.
      • setBaseCalendar

        public 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 com.aspose.tasks.Calendar.

        Parameters:
        value - base calendar.
      • isBaselineCalendar

        public boolean isBaselineCalendar()

        Specifies whether the calendar is a baseline calendar. Read/write boolean. This is a new for MS Project 2010 property. Reading supported for XML format only. Returns false if not defined.

        Returns:
        true if a calendar is a baseline calendar.
      • setBaselineCalendar

        public void setBaselineCalendar(boolean value)

        Specifies whether the calendar is a baseline calendar. Read/write boolean. This is a new for MS Project 2010 property. Reading supported for XML format only. Returns false if not defined.

        Parameters:
        value - true if a calendar is a baseline calendar.
      • getParentProject

        public Project getParentProject()

        Returns parent project for this calendar. Read only Calendar.

        Returns:
        parent project for this calendar.
      • makeStandardCalendar

        public static Calendar makeStandardCalendar()

        Creates default standard calendar.

        Returns:
        Created calendar.
      • makeStandardCalendar

        public static Calendar makeStandardCalendar(Calendar calendar)

        Creates default standard calendar.

        Parameters:
        calendar - the specified calendar to make standard calendar for.
        Returns:
        Created calendar.
      • make24HourCalendar

        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.

        Returns:
        Created 24Hour Calendar.
      • make24HourCalendar

        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.

        Parameters:
        calendar - Calendar to make 24 Hours Calendar from.
        Returns:
        24Hour Calendar.
      • makeNightShiftCalendar

        public static Calendar makeNightShiftCalendar()

        Creates Night Shift Calendar named "Night shift".

        Returns:
        Created Night Shift Calendar.
      • makeNightShiftCalendar

        public static Calendar makeNightShiftCalendar(Calendar calendar)

        Makes a given Calendar as Night Shift Calendar.

        Parameters:
        calendar - Calendar to make Night Shift Calendar.
        Returns:
        Night Shift Calendar.
      • equals

        public boolean equals(Object obj)

        Returns a value indicating whether this instance is equal to a specified object.

        Overrides:
        equals in class Object
        Parameters:
        obj - The object to compare with this instance.
        Returns:
        <b>True</b> if o is a Calendar that has the same Uid value as this instance; otherwise, <b>false</b>.
      • hashCode

        public int hashCode()

        Returns a hash code for the instance of the Calendar class.

        Overrides:
        hashCode in class Object
        Returns:
        a hash code for this object.
      • delete

        public void delete()

        Removes calendar from project.

      • getStartDateFromFinishAndDuration

        public Date getStartDateFromFinishAndDuration(Date finish,
                                                      Duration duration)

        Returns StartDate based on specified FinishDate and Duration.

        Parameters:
        finish - the specified finishDate.
        duration - the specified duration.
        Returns:
        Calculated StartDate.
      • getStartDateFromFinishAndDuration

        public Date getStartDateFromFinishAndDuration(Date finish,
                                                      double duration)

        Returns StartDate based on specified FinishDate and Duration.

        Parameters:
        finish - the specified finishDate.
        duration - the specified duration.
        Returns:
        Calculated StartDate.
      • isDayWorking

        public boolean isDayWorking(Date dt)
        /**

        Determines whether the day is working day.

        Parameters:
        dt - the date
        Returns:
        True if the day is working day; otherwise, false.
      • getWorkingHours

        public WorkUnit getWorkingHours(Date start,
                                        Date finish)

        Return working hours for the specified dates.

        Parameters:
        start - Start date.
        finish - Finish date.
        Returns:
        Working hours.
      • getFinishDateByStartAndWork

        public Date getFinishDateByStartAndWork(Date start,
                                                Duration work)

        Calculates the date when the specified amount of work time will pass according to the calendar.

        Parameters:
        start - Start date.
        work - Work duration.
        Returns:
        Finish date.
      • getFinishDateByStartAndWork

        public Date getFinishDateByStartAndWork(Date start,
                                                double work)

        Calculates the date when the specified amount of work time will pass according to the calendar.

        Parameters:
        start - Start date.
        work - Work duration.
        Returns:
        Finish date.
      • getTaskFinishDateFromDuration

        public Date getTaskFinishDateFromDuration(Task task,
                                                  double duration)

        Calculates the task finish date and time from its start date, split parts and the duration.

        Parameters:
        task - Task.
        duration - New task duration.

        Returns DateTime.MinValue if task is summary, null or its start date is not set.

        Returns:
        Task's finish date.
      • getWorkingHours

        public double getWorkingHours(Date dt)

        Returns amount of working hours at the date.

        Parameters:
        dt - The date.
        Returns:
        Working hours.
      • getWorkingTimes

        public WorkingTimeCollection getWorkingTimes(Date dt)

        Returns WorkingTimeCollection of working times for the specified date.

        Parameters:
        dt - The specified date to getInternal working times for.
        Returns:
        List of WorkingTime.
      • getPreviousWorkingDayEnd

        public Date getPreviousWorkingDayEnd(Date date)

        Calculates previous working date end from the specified date.

        Parameters:
        date - the specified instance of DateTime struct.
        Returns:
        Previous working day start System.DateTime
      • getNextWorkingDayStart

        public Date getNextWorkingDayStart(Date date)

        Calculates next working day start from the date.

        Parameters:
        date - The date.
        Returns:
        Next working day start System.DateTime.