using System;
public class MainClass
{
public static void Main()
{
string[] dateStrings = {"2010-05-01T07:34:42-5:00",
"2010-05-01 7:34:42Z",
"Thu, 01 May 2010 07:34:42 GMT"};
foreach (string dateString in dateStrings)
{
DateTime convertedDate = DateTime.Parse(dateString);
Console.WriteLine(convertedDate.Kind.ToString());
Console.WriteLine(convertedDate);
}
}
}
13.4.DateTime Parse ParseExact |
| 13.4.1. | DateTime.Parse: Sep 2005 |
| 13.4.2. | DateTime.Parse: Monday 5 September 2005 14:16:31 |
| 13.4.3. | DateTime.Parse: 5,9,05 |
| 13.4.4. | DateTime.Parse: 5/9/2005 14:15:33 |
| 13.4.5. | DateTime.Parse: 2:15 PM |
| 13.4.6. | DateTime.ParseExact: (2:13:30 PM, h:mm:ss tt, null) |
| 13.4.7. | DateTime.ParseExact: Mon, 05 Sep 2005 14:13:30 GMT, ddd, dd MMM yyyy HH':'mm':'ss 'GMT', null |
| 13.4.8. | DateTime.ParseExact: September 05, MMMM dd, null |
| 13.4.9. | Use the Parse() method to convert strings to DateTime instances: 1/11/2004 |
| 13.4.10. | Use the Parse() method to convert strings to DateTime instances: 1/11/2004 23:10:30 |
| 13.4.11. | DateTime.Parse and DateTime.Kind |
| 13.4.12. | Parse string with date but no time component |