Parse string with date but no time component : DateTime Parse ParseExact « Date Time « C# / CSharp Tutorial
- C# / CSharp Tutorial
- Date Time
- DateTime Parse ParseExact
using System;
using System.Globalization;
public class DateTimeParser
{
public static void Main()
{
DateTime dateValue;
string dateString = "2/16/2008";
try {
dateValue = DateTime.Parse(dateString);
Console.WriteLine("'{0}' converted to {1}.", dateString, dateValue);
}
catch (FormatException) {
Console.WriteLine("Unable to convert '{0}'.", dateString);
}
}
}
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 |