私はc#のコードの下にあり、文字列型の形式の日付を日時に変換していますが、エラーが発生します。
if (!string.IsNullOrEmpty(SessionDictionary.GetValue("UserDetails", "ExpiryDate")))
{
DateTime ExpiryDate = DateTime.ParseExact(SessionDictionary.GetValue("UserDetails", "ExpiryDate"), "dd mmm yy", null);
strDate = sitedata.FormatDate(ExpiryDate, TridionDateFormat.ShortDate);
}
else
{
strDate = "-";
}
私SessionDictionary.GetValue("UserDetails", "ExpiryDate")
は文字列型のデータで、「31/01/2011 00:00:00」形式の日付を返します。上記のコードで使用しDateTime.ParseExact
ていると、System.FormatException: String was not recognized as a valid DateTime.
エラーが発生します。
何が悪いのか提案してください。
ありがとう。