How to judge if the actual start date is empty?

Hi,



I can get the value of actual start date by “task.get(Tsk.ACTUAL_START)”, I’d like to know how to judge if the actual start date is empty when the value is ‘N/A’ in MSP.


Best Regards!
zhencheng.guo

Hi Zhencheng,


Thank you for contacting Aspose support team again.

Aspose.Tasks sets minimum date value in the date fields which are not set in the project. You may try following sample code which identifies empty ActualStart field in the attached sample project file. Task 1 contains NA value where as Task 2 contains proper date.

<span style=“font-size: 9pt; font-family: “Courier New”;”>Project proj = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
<span style=“font-size: 9pt; font-family: “Courier New”;”>Project(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>"
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>ActualStartNA.xml"
<span style=“font-size: 9pt; font-family: “Courier New”;”>);



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

tempDate.set(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>1<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>1<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>, <span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>);

Date MinDate = tempDate.getTime();



Task task1 = proj.getRootTask().getChildren().getByUid(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>1<span style=“font-size: 9pt; font-family: “Courier New”;”>);

Date dt1 = task1.get(Tsk.<span style=“font-size:9.0pt;font-family:
“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_START
<span style=“font-size: 9pt; font-family: “Courier New”;”>);

<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>if
<span style=“font-size: 9pt; font-family: “Courier New”;”>(dt1.toString().compareTo(MinDate.toString())
== <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>)

System.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out
<span style=“font-size: 9pt; font-family: “Courier New”;”>.println(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“NA”
<span style=“font-size: 9pt; font-family: “Courier New”;”>);

<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>else

<span style=“font-size: 9pt; font-family: “Courier New”;”>System.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
<span style=“font-size: 9pt; font-family: “Courier New”;”>.println(dt1.toString());



Task task2 = proj.getRootTask().getChildren().getByUid(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>2<span style=“font-size: 9pt; font-family: “Courier New”;”>);

Date dt2 = task2.get(Tsk.<span style=“font-size:9.0pt;font-family:
“Courier New”;mso-fareast-font-family:“Times New Roman”;color:#660E7A”>ACTUAL_START
<span style=“font-size: 9pt; font-family: “Courier New”;”>);

<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>if
<span style=“font-size: 9pt; font-family: “Courier New”;”>(dt2.toString().compareTo(MinDate.toString())
== <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:blue”>0<span style=“font-size: 9pt; font-family: “Courier New”;”>)

System.<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:#660E7A”>out
<span style=“font-size: 9pt; font-family: “Courier New”;”>.println(<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“NA”
<span style=“font-size: 9pt; font-family: “Courier New”;”>);

<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>else

<span style=“font-size: 9pt; font-family: “Courier New”;”>System.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
<span style=“font-size: 9pt; font-family: “Courier New”;”>.println(dt2.toString());

Hi ,


In case the actual start date in the MSP is just ‘1/1/01 00:00:00’, it is not empty at this point, how can I do?
One more thing, I observed the empty is not always parsed to ‘1/1/01 00:00:00’, sometimes the empty will be parsed to ‘1/1/01 01:00:00’, how to do in this case?

Best Regards!
zhencheng.guo
Hi Zhencheng,

Thank you for writing us back.

Please forward us a sample input file which shows date like '1/1/01 01:00:00' and not always parsing to '1/1/01 00:00:00'. This will help us to reproduce the issue at our end.