Hi Zhencheng,
Project asProject = new Project("Empty_Project.mpp");
asProject.set(Prj.START_DATE, formatter2.parse("09/27/02
08:00:00"));
asProject.set(Prj.FINISH_DATE, formatter2.parse("12/30/02
08:00:00"));
asProject.setCalculationMode(CalculationMode.None);
Task f1 = asProject.getRootTask().getChildren().add("Release 5.0");
f1.set(Tsk.START, formatter2.parse("09/27/02
08:00:00"));
f1.set(Tsk.FINISH, formatter2.parse("09/28/02
08:00:00"));
f1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
Task f1_1_1_1 = f1.getChildren().add("Top-Down
Project Planning");
f1_1_1_1.set(Tsk.START, formatter2.parse("09/27/02
08:00:00"));
f1_1_1_1.set(Tsk.FINISH, formatter2.parse("09/28/02
08:00:00"));
f1_1_1_1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
f1_1_1_1.set(Tsk.WORK, asProject.getDuration(4, TimeUnitType.Hour));
f1_1_1_1.set(Tsk.CONSTRAINT_DATE, formatter2.parse("09/27/02
08:00:00"));
f1_1_1_1.set(Tsk.CONSTRAINT_TYPE, ConstraintType.StartNoEarlierThan);
asProject.recalculate();
asProject.save("test_create_actual.mpp", SaveFileFormat.MPP);
System.out.println("ok");
Hi kashif,
Hi Kashif,
Actually, even if I set the constraint, it doesn’t work.
Hi Zhencheng,
Hi Jay,
kashif.iqbal:Hi Zhencheng,Thank you for writing to Aspose support team.You may use constraint date and type as well to get the proper date here. Please give try to the following sample code and share the feedback.
Project asProject = new Project("Empty_Project.mpp");
asProject.set(Prj.START_DATE, formatter2.parse("09/27/02 08:00:00"));
asProject.set(Prj.FINISH_DATE, formatter2.parse("12/30/02 08:00:00"));
asProject.setCalculationMode(CalculationMode.None);
Task f1 = asProject.getRootTask().getChildren().add("Release 5.0");
f1.set(Tsk.START, formatter2.parse("09/27/02 08:00:00"));
f1.set(Tsk.FINISH, formatter2.parse("09/28/02 08:00:00"));
f1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
Task f1_1_1_1 = f1.getChildren().add("Top-Down Project Planning");
f1_1_1_1.set(Tsk.START, formatter2.parse("09/27/02 08:00:00"));
f1_1_1_1.set(Tsk.FINISH, formatter2.parse("09/28/02 08:00:00"));
f1_1_1_1.set(Tsk.DURATION, asProject.getDuration(1, TimeUnitType.Day));
f1_1_1_1.set(Tsk.WORK, asProject.getDuration(4, TimeUnitType.Hour));
f1_1_1_1.set(Tsk.CONSTRAINT_DATE, formatter2.parse("09/27/02 08:00:00"));
f1_1_1_1.set(Tsk.CONSTRAINT_TYPE, ConstraintType.StartNoEarlierThan);
asProject.recalculate();
asProject.save("test_create_actual.mpp", SaveFileFormat.MPP);
System.out.println("ok");
Hi Zhencheng,