c# - DateTime.Parse throws exception "not support in System.Globalization.GregorianCalendar" -
string formatstring = "mmddyyyyhhmmss"; string sample = "20100611221912"; datetime dt = datetime.parseexact(sample, formatstring, system.globalization.cultureinfo.invariantculture); the specific exception thrown is:
system.formatexception: datetime represented string not supported in calendar system.globalization.gregoriancalendar.
your format should be:
string formatstring = "yyyymmddhhmmsss"; (it can "yyyyddmmhhmmsss", if 06-noveber-2010)
considering date dt = {11/06/2010 10:19:12 pm} (11-june-2010)
for current format:
mmddyyyyhhmmss 20100611221912 mm can't 20, since mm stands month. code should be:
string formatstring = "yyyymmddhhmmsss"; string sample = "20100611221912"; datetime dt = datetime.parseexact(sample, formatstring, system.globalization.cultureinfo.invariantculture);
Comments
Post a Comment