I have a program that returns date formatting errors for the data im submitting. When i do a request to the SOAP endpoint i get formatting errors like :
2020-01-30 18:27:22,820|MethodFilter@ff7cd8 |SSException Throwing com.systemsunion.util.datatype.formatting.InvalidExternalDateLengthException
Message : The external date value '7252019' is not the correct length. The correct format is DDMMYYYY.
Stack Trace :
com.systemsunion.util.datatype.formatting.InvalidExternalDateLengthException: The external date value '7252019' is not the correct length. The correct format is DDMMYYYY.
at com.systemsunion.util.datatype.formatting.DateFormatter.getInternalFormat(Unknown Source)
and another as :
2020-01-30 18:27:22,825|MethodFilter@ff7cd8 |SSException Throwing com.systemsunion.util.datatype.formatting.InvalidExternalDateException
Message : The external date value '10302019' is invalid. The correct date format is DDMMYYYY.
Stack Trace :
com.systemsunion.util.datatype.formatting.InvalidExternalDateException: The external date value '10302019' is invalid. The correct date format is DDMMYYYY.
at com.systemsunion.util.datatype.formatting.DateFormatter.getInternalFormat(Unknown Source)
.
Example source dates i have include :
2019-09-03T00:00:00
2019-09-26T00:00:00
2019-11-26T00:00:00
and
Expected Output in each case is :
03092019
26092019
26112019
What I have tried:
I have tried formatting the input in my source as below but i think the logic is not converting as correctly as expected:
string dateSeparator = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator;
string dateTime = transaction.Cover_start_date;
DateTime dt = Convert.ToDateTime(dateTime);
var dateOnlyString = dt.ToShortDateString().Replace(dateSeparator, "");
where
transaction.Cover_start_date
is the source date from my model. Any help on what i might be missing. I am especially suspicious of the first exception where the error points to the converted date as
'7252019'
. As it is the all the dates coming in from the model are valid dates and im not entirely sure what was the original value of
'7252019'
when in was in its source form i.e
YYYY-MM-DDT12:48:15