Defining Weekdays for Exceptions

When setting up calendar exceptions with Aspose.Tasks for Java, it is possible to define days as exceptions.

Defining Workdays The Exceptions collection exposed by the Calendar class can be used to define the weekdays for an exception.

To see a list of exceptions in Microsoft Project:

  1. Open a file.
  2. From the Tools menu, select Change Working Time to open the Change Working Time dialog. The screenshot below shows the dialog for the project saved with the code below.

Exceptions defined for working days

defining in calendar exceptions in weekdays Microsoft Project

Programming Sample

The following example defines the dates 24-Dec-2009 through 31-Dec-2009 as exceptions.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(DefineWeekdaysForExceptions.class);
 4
 5// Create a project instance
 6Project project = new Project();
 7
 8// Define Calendar
 9Calendar cal = project.getCalendars().add("Calendar1");
10
11// Define week days exception for Christmas
12CalendarException except = new CalendarException();
13except.setEnteredByOccurrences(false);
14
15java.util.Calendar calObject = java.util.Calendar.getInstance();
16calObject.set(2009, 12, 24, 0, 0, 0);
17except.setFromDate(calObject.getTime());
18calObject.set(2009, 12, 31, 23, 59, 0);
19except.setToDate(calObject.getTime());
20except.setType(CalendarExceptionType.Daily);
21except.setDayWorking(false);
22cal.getExceptions().add(except);
23
24project.save(dataDir + "Project.Xml", SaveFileFormat.XML);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.