I am reading an input from a device on a comm port, that is a date in the following format "dd/MM/yyyy hh:mm" to a string value. I am trying to format the date to show "ddMMyyyy hh:mm:ss". I have tried the following but get the error below code:
(input value is "31/08/2018 02:32")
public string ParseLine(string Line)
{
var input = Line.Split(',');
var dateTime = DateTime.Parse (input[0]);
var Action = input[1] == "1" ? "ONL" : "OFL";
var readerAddr = input[1] == "1" ? "S" : "T";
var TagType = input[2];
var TagNum = input[3].Substring(TagType.Length);
return $"{Action},{TagNum},{readerAddr},{dateTime:ddMMyyyy hh:mm:ss}";
}
Any advise will be appreciated?