C# - Am I replacing perfectly good code?
<p>I had a quick function to format a date, here it is:</p>

<pre><code>public static string archiveServerDateTime(string datetime)
    {
        DateTime tempDateTime = DateTime.ParseExact(datetime,"dd.MM.yyyy HH:mm:ss", null);
        return tempDateTime.ToString("yyyy/MM/dd:HH:mm:ss");
    }
</code></pre>

<p>only to find the output of the function = 2009.10.22:16:21:03, and amazingly this is only on 1 production server, test server worked perfectly fine......</p>

<p>So now I rewrote the function to old school style:</p>

<pre><code>public static string archiveServerDateTime(string datetime)
    {
        DateTime tempDateTime = DateTime.ParseExact(datetime,"dd.MM.yyyy HH:mm:ss", null);
        string yearPart = Convert.ToString(tempDateTime.Year);
        string monthPart = Convert.ToString(tempDateTime.Month).PadLeft(2,'0');
        string dayPart = Convert.ToString(tempDateTime.Day ).PadLeft(2, '0');
        string hourPart = Convert.ToString(tempDateTime.Hour).PadLeft(2, '0');
        string minutePart = Convert.ToString(tempDateTime.Minute).PadLeft(2, '0'); 
        string secondPart = Convert.ToString(tempDateTime.Second).PadLeft(2,'0');

        return yearPart + @"/" + monthPart + @"/" + dayPart + ":" + hourPart + ":" + minutePart + ":" + secondPart; 
        //return tempDateTime.ToString("yyyy/MM/dd:HH:mm:ss");
    }
</code></pre>

<p>So I ask you ladies and gentlemen, was I replacing perfectly good code to begin with, or is this a Microsoft bug of some kind? Can we really trust these new language features that are seemingly not so rock solid, or am I just missing something?</p>
