Hi Experts,
My requirement is to send the date from yyyy-MM-dd'T'HH:mm:ss.SSSXXX to yyyyMMddHHmmssSSS.
But sometimes, the data is received without milliseconds, due to this my groovy script is failing with an unparsable date issue.
Works when the date is in 2022-11-30T11:45:53.243+01:00 format
Fails when the date is in 2022-11-30T11:45:53+01:00 format
import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.json.*
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
def Message processData(Message message) {
String mod_time = message.getProperty("PL_ModificationTime");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
Date MOD = sdf.parse(mod_time);
message.setProperty("ModificationTime", MOD.format("yyyyMMddHHmmssSSS"));
return message;
}
Any leads to fix this issue in the below groovy script will be really helpful.
Regards,
Pavan