Unable to set Finish date on a Task

Hi,


I am not able to achieve a simple objective. I am trying to create a simple project with a simple task that starts on 29th December 2016 and ends 4 Jan 2016. Please provide a simple code sample for this.

Hi George,

Thank you for contacting Aspose support team.

You may set the task start date and duration instead of start/finish date. Please give a try to the following sample code which creates a task and sets its start date and duration.

java.util.Calendar;

startDate = java.util.Calendar.getInstance();

startDate.set(2016, 11, 29, 8, 0, 0);

Project project1 = new Project(“Blank2010.mpp”);
project1.set(Prj.START_DATE, startDate.getTime());
Task task1 = project1.getRootTask().getChildren().add(“Task 1”);
task1.set(Tsk.START, startDate.getTime());
task1.set(Tsk.DURATION, project1.getDuration(40, TimeUnitType.Hour));
project1.save(“project1.mpp”, SaveFileFormat.MPP);

Please feel free to write us back if you have any other query in this regard.