У меня есть строковое представление DateTime, которое выглядит так:
2011-05-25T16:42:17.156Z
Я безуспешно пробовал следующее:
DateTime.ParseExact(formatted, "yyyy-MM-ddThh:mm:ss.fffZ", CultureInfo.CurrentCulture);
DateTime.ParseExact(formatted, "yyyy-MM-dd hh:mm:ss.fff", CultureInfo.CurrentCulture);
DateTime.ParseExact(formatted, CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(), CultureInfo.CurrentCulture, DateTimeStyles.AssumeUniversal);
DateTime.ParseExact(formatted, CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(), CultureInfo.CurrentCulture, DateTimeStyles.None);
Все они дают ошибку:
String was not recognized as a valid DateTime.
Стандартный DateTime.Parse, кажется, работает, хотя по соображениям производительности мы изучаем ParseExact. Похоже, что это должно быть довольно просто, но не может заставить его работать.