J
js
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss".
I need to parse the text using System.DateTime.Parse() function with
custom format. I got an error using the following code. Could someone
help me with the customization? Thanks.
String was not recognized as a valid DateTime. at
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles) at System.DateTime.Parse(String s,
IFormatProvider provider, DateTimeStyles styles)
***** My code ****
CultureInfo format = (CultureInfo)
Thread.CurrentThread.CurrentCulture.Clone();
format.DateTimeFormat.Calendar YearMonthPattern = "yyyy'/'MM'";
format.DateTimeFormat.MonthDayPattern = "MM'/'dd";
this.calDate.SelectedDate = System.DateTime.Parse(this.txtDate.Text,
format, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
I need to parse the text using System.DateTime.Parse() function with
custom format. I got an error using the following code. Could someone
help me with the customization? Thanks.
String was not recognized as a valid DateTime. at
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles) at System.DateTime.Parse(String s,
IFormatProvider provider, DateTimeStyles styles)
***** My code ****
CultureInfo format = (CultureInfo)
Thread.CurrentThread.CurrentCulture.Clone();
format.DateTimeFormat.Calendar YearMonthPattern = "yyyy'/'MM'";
format.DateTimeFormat.MonthDayPattern = "MM'/'dd";
this.calDate.SelectedDate = System.DateTime.Parse(this.txtDate.Text,
format, System.Globalization.DateTimeStyles.NoCurrentDateDefault);