The issue of change duration

Hi,

Please run the code as below:


public static void main(String[] args) throws ParseException {
FileInputStream fstream = null;

try {
// Create a stream object containing the license file
fstream = new FileInputStream("Aspose.Tasks.lic");
// Instantiate the License class
License license = new License();
// Set the license through the stream object
license.setLicense(fstream);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fstream.close();
} catch (IOException e) {
e.printStackTrace();
}
}

Project asProject = new Project("Task-Assignment-Test.mpp");

com.aspose.tasks.Task asTaskUID_2 = asProject.getRootTask().getChildren().getByUid(2);
com.aspose.tasks.Task asTaskUID_3 = asProject.getRootTask().getChildren().getByUid(3);
System.out.println(asTaskUID_2.get(Tsk.START));
System.out.println(asTaskUID_3.get(Tsk.START));
asTaskUID_2.set(Tsk.DURATION, asProject.getDuration(4, TimeUnitType.Day));
System.out.println(asTaskUID_2.get(Tsk.START));
System.out.println(asTaskUID_3.get(Tsk.START));

asProject.save("output_change_duration.mpp", SaveFileFormat.MPP);
}

At the beginning, the "Start" of asTaskUID_2 and asTaskUID_3 are both "1/30/2005', then I changed the "Duration" of asTaskUID_2, why the "Start" of asTaskUID_2 and asTaskUID_3 trun to "5/25/2005"?

zhencheng.guo
Best Regards!

Hi Zhencheng,


Thank you for writing to Aspose support team.

Open the Task-Assignment-Test.mpp in MSP and observe the project start date which is May 25, 2005. You may please set the project start date properly i.e. earlier than any task in the project and issue will be resolved. Please modify the code as mentioned below and share the feedback.


Project asProject = new Project(“Task-Assignment-Test.mpp”);
asProject.set(Prj.START_DATE, formatter2.parse(“1/3/05 08:00:00”));