Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
指定された文字列が有効なカスタマイズされた形式 "yyyy-MM-dd h:mm:ss" であるかどうかを確認する方法は?
例えば:
2013-09-09 05:25:40
は有効な形式です。
と
09-09-2013 05:25:40
は無効な形式です。
これには DateTime.TryParseExact() を使用できます。
if(DateTime.TryParseExact(yourDate, "yyyy-MM-dd h:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue)) { // DateTime parsed, dateValue contains the parsed DateTime }