Calculating a Split Task's Finish Date

Microsoft Project allows users to split tasks when the schedule is interrupted. Aspose.Tasks allows you to calculate the finishing date of a split task.

Split Tasks

The getTaskFinishDateFromDuration method exposed by the Calendar class is used to calculate a split task’s finishing date from the start date, split parts, and duration. The getTaskFinishDateFromDuration method takes a split task and duration as its arguments and returns the tasks finish date.

Split Tasks in Microsoft Project

To view the start date of a split task in Microsoft Project from the View menu, select Gantt Chart. The parts of a split task are connected by a line of dots.

The split task in Microsoft Project split task in Microsoft Project

Calculating a Split Task’s Finish Date with Aspose.Tasks

The following code examples calculate a split task’s finish date.

 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(SplitTaskFinishDate.class);
 4
 5// Read project
 6String projectName = dataDir + "SplitTaskProject.mpp";
 7Project project = new Project(projectName);
 8
 9// Find a split task
10Task splitTask = project.getRootTask().getChildren().getByUid(1);
11
12// Find the project calendar
13Calendar calendar = project.get(Prj.CALENDAR);
14
15// Calculate task's finish date with different durations
16System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 8 hours\nFinish Date: "
17        + calendar.getTaskFinishDateFromDuration(splitTask, 8d));
18System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 16 hours\nFinish Date: "
19        + calendar.getTaskFinishDateFromDuration(splitTask, 16d));
20System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 24 hours\nFinish Date: "
21        + calendar.getTaskFinishDateFromDuration(splitTask, 24d));
22System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 28 hours\nFinish Date: "
23        + calendar.getTaskFinishDateFromDuration(splitTask, 28d));
24System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 32 hours\nFinish Date: "
25        + calendar.getTaskFinishDateFromDuration(splitTask, 32d));
26System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 46 hours\nFinish Date: "
27        + calendar.getTaskFinishDateFromDuration(splitTask, 46d));
28System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 61 hours\nFinish Date: "
29        + calendar.getTaskFinishDateFromDuration(splitTask, 61d));
30System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 75 hours\nFinish Date: "
31        + calendar.getTaskFinishDateFromDuration(splitTask, 75d));
32System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 80 hours\nFinish Date: "
33        + calendar.getTaskFinishDateFromDuration(splitTask, 80d));
34System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 120 hours\nFinish Date: "
35        + calendar.getTaskFinishDateFromDuration(splitTask, 120d));
36System.out.println("Start Date: " + splitTask.get(Tsk.START) + "\n+ Duration 150 hours\nFinish Date: "
37        + calendar.getTaskFinishDateFromDuration(splitTask, 150d));
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.