よく忘れるので、メモ。
// vim:set ts=4 sw=4 et ws is nowrap ft=cs: using System; namespace Gsf.Samples.Tmp{ public class DateTimeParseExactSample : IExecutor{ public void Execute(){ // // 指定した日付文字列から日付オブジェクトを取得。 // // 最後の引数はIFormatProviderとなっており、nullを渡すと // 現在のカルチャの書式情報が使用される。 // string targetDateString = "20071001101112"; string targetDateFormat = "yyyyMMddHHmmss"; DateTime d = DateTime.ParseExact(targetDateString, targetDateFormat, null); Console.WriteLine("{0} {1}", d.ToShortDateString(), d.ToLongTimeString()); } } }