/******************************************************************
* 创建人:HTL
* 创建时间:2015-04-08 15:36:35
* 说明:C# 使用DateTime.TryParseExact将自定义日期类型转换成日期
* Email:huangyuan413026@163.com
*******************************************************************/
using System;
public class DateTime_TryParseExact_Demo
{
public static void Main()
{
string str = DateTime.Now.ToString("yyyyMMdd");
string[] format = {"yyyyMMdd"};
DateTime date;
if (DateTime.TryParseExact(str,
format,
System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None,
out date))
{
Console.WriteLine("Custom DateTime Type Convert success:"+date.ToString());
}
else
Console.WriteLine("Custom DateTime Type Convert error ");
}//end Main
}//end
LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKgogKiDliJvlu7rkurrvvJpIVEwKICog5Yib5bu65pe26Ze077yaMjAxNS0wNC0wOCAxNTozNjozNQogKiDor7TmmI7vvJpDIyDkvb/nlKhEYXRlVGltZS5UcnlQYXJzZUV4YWN05bCG6Ieq5a6a5LmJ5pel5pyf57G75Z6L6L2s5o2i5oiQ5pel5pyfCiAqIEVtYWls77yaaHVhbmd5dWFuNDEzMDI2QDE2My5jb20KICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgp1c2luZyBTeXN0ZW07CgpwdWJsaWMgY2xhc3MgRGF0ZVRpbWVfVHJ5UGFyc2VFeGFjdF9EZW1vCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQlzdHJpbmcgc3RyID0gRGF0ZVRpbWUuTm93LlRvU3RyaW5nKCJ5eXl5TU1kZCIpOwoJCXN0cmluZ1tdIGZvcm1hdCA9IHsieXl5eU1NZGQifTsKCQlEYXRlVGltZSBkYXRlOwoKCQlpZiAoRGF0ZVRpbWUuVHJ5UGFyc2VFeGFjdChzdHIsIAoJCSAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvcm1hdCwgCgkJICAgIC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