I would like to add an IFieldInstance to a document which is in the model described as DateTimeType but I get an Error.
The relevent part of the model:
{
"type": "Field",
"id": "field_d8d6b",
"name": "timestamp_last_edit",
"Field": {
"fieldType": {
"type": "DateTimeType",
"DateTimeType": {
"format": "yyyy-MM-dd'T'HH:mm:ss"
}
},
"label": [
{
"locale": "en",
"text": "Last edit"
}
]
}
}
How the date-time is added:
IFieldInstance fieldInstance = documentFactory.createFieldInstance(fieldToPath(field), repitition);
document.removeEntityInstance(fieldInstance);
fieldInstance.setValue("2023-02-01T11:28:40");
document.addEntityInstance(fieldInstance);
The error:
Caused by: java.lang.IllegalArgumentException: The given value is syntactically wrong and that's why it cannot be converted to the corresponding approximated date-object.
at com.mgmtp.a12.kernel.core.rt._27_3_0.internal.util.TeilbekanntesDatumUtil.parseApproximatedDate(TeilbekanntesDatumUtil.java:248)
at com.mgmtp.a12.kernel.md.facade.a12internal.KernelUtils.getApproximatedDate(KernelUtils.java:61)
at com.mgmtp.a12.dataservices.model.internal.TimeFormatUtils.handlePartiallyKnownDates(TimeFormatUtils.java:92)
at com.mgmtp.a12.dataservices.search.internal.AbstractIndexDocument.lambda$addDateField$10(AbstractIndexDocument.java:97)
It seems like A12 is using the parseApproximatedDate() function which only uses “yyyy-MM-dd” and therefore the format does not match.
Why is it using approximateDate?
How to set the date time correctly on the fieldInstance?