Primavera P6: date/time parsing (PrimaveraXERFileReader)
alex-matatov opened this issue · comments
Hi Jon,
Even #579 was false alarm there is still date/time parse issue in mpxj lib.
This time I am sure that our test XER file was not produced by our software and is an original P6 one.
Seems, Primavera P6 v16 and higher uses date/time format like this -> 2021-09-13 08:00
and mpxj parses it successfully.
However, Primavera P6 v15 uses a little bit different format -> 2021-9-13 08:00
(1 digit for January..September months) . This time mpxj fails to parse it.
The fix is quite trivial.. In PrimaveraXERFileReader
date/time formatter could be changed like below (use only 1 M
). SO, both 2021-09-13 08:00
and 2021-9-13 08:00
will be parsed correctly.
private final DateTimeFormatter m_df = DateTimeFormatter.ofPattern("yyyy-M-dd[ HH:mm[:ss]]");
Also, if DateTimeFormater
from net.sf.mpxj.primavera.DatatypeConverter
will be changed to ISO one (see my last comment here that PrimaveraPMFileReader
will support more date/time formats:
2023-09-28T17:00:00.56
2023-09-28T17:00:00
2023-09-28T17:00
Note:
Currently, if mpxj can't parse date/time string (xer and xml) it silently (even without warning) ignores it and sets NULL to the corresponding field. So there could be a situation that technically P6 project is loaded but all or some of Tasks have planningStartDate == NULL
. This situation could lead to incorrect data processing later.
I would suggest to throw "Unexpected date/time format" exception in this case (or do it when reader.setIgnoreErrors(false)
) .
I've updated the format to handle single digit months. I'll have a look at the date/time parse error handling.
I've made some changes to error handling in #585. Readers which are by default silently ignoring some data type conversion errors can now be configured using the setIgnoreErrors()
. If the default behavior of ignoring errors is used, the new method ProjectFile.getIgnoredErrors()
can be used to retrieve details of any ignored errors.