How to format DateTime using ToString
Another WTF:
// I saw this code today and went WTF!!!!
string oldway = DateTime.Now.Year + "-" +
DateTime.Now.Month.ToString("00") + "-" + DateTime.Now.Day.ToString("00") +
"T" + DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00") +
":" + DateTime.Now.Second.ToString("00");
// I changed it to this
string newWay = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
// And to prove it worked I placed it all in a test and checked that both returns the same result.
Assert.AreEqual(oldway, newWay);