HI,
Please run the code as below :
public class TestCreateActual {
private static SimpleDateFormat formatter2 = new SimpleDateFormat("MM/dd/yy");
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("Empty_Project.mpp");
asProject.set(Prj.START_DATE, formatter2.parse("2/6/16 08:00:00"));
asProject.setCalculationMode(CalculationMode.None);
com.aspose.tasks.Resource test1Resource = asProject.getResources().add("test1");
Task f1 = asProject.getRootTask().getChildren().add("Release 5.0");
Date startDate = formatter2.parse("2/6/2017");
Date finishDate = formatter2.parse("2/10/2017");
Date actualStartDate = formatter2.parse("2/8/2017");
f1.set(Tsk.START, startDate);
f1.set(Tsk.FINISH, finishDate);
f1.set(Tsk.DURATION, asProject.getDuration(5, TimeUnitType.Day));
f1.set(Tsk.ACTUAL_START, actualStartDate);
f1.set(Tsk.ACTUAL_WORK, asProject.getDuration(30, TimeUnitType.Hour));
f1.set(Tsk.PERCENT_COMPLETE, 75);
ResourceAssignment ra1 = asProject.getResourceAssignments().add(f1, test1Resource);
ra1.set(Asn.START, startDate);
ra1.set(Asn.ACTUAL_START, actualStartDate);
ra1.set(Asn.ACTUAL_WORK, asProject.getDuration(30, TimeUnitType.Hour));
ra1.set(Asn.PERCENT_WORK_COMPLETE, 75);//
asProject.recalculate();
asProject.save("test_create_actual.mpp", SaveFileFormat.MPP);
System.out.println("ok");
}
}
I have set the actual start to "2/8/2017", why the result of actual start is "2/6/2017"?
Best Regards!
zhencheng.guo