Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net mvc - C# DateTime.ParseExact throwing format exception -


i'm developing .net4 webapplication using mvc3.

let's i'm getting following datetime string xml-feed. xml feed being read application , i'm looping through it's descendants. datetime i'm receiving begin returned in following format (as string);

var mydatetime = "sun dec 19 11:45:45 +0000 2010" 

i'm using piece of code below try , parse datetime string mentioned above valid datetime format (preferably dutch)

var correctdatetime = datetime.parseexact(mydatetime , "dd mmm yyyy hh:mm:ss", cultureinfo.invariantculture); 

when trying execute code i'm facing formatexception. has got ideas?

--update--

this i've got after various answers. still throwing same exception though.

var correcteddatetime = datetime.parseexact(latesttweettime, "ddd mmm hh:mm:ss k yyyy", cultureinfo.invariantculture); string display = correcteddatetime.tostring("dd mmm yyyy hh:mm:ss"); 

if you're trying read this: "sun dec 19 11:45:45 +0000 2010"

you need additional "d" or "dd" so:

"ddd mmm d hh:mm:ss k yyyy" 

or

"ddd mmm dd hh:mm:ss k yyyy" 

depending on whether input zero-prefixed.

you need each piece of input string accounted for, here summary of different components msdn: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

ddd = 3 letter day of week mmm = 3 letter month dd = 2 digit day of month 01-31  (use "d" 1-31) hh = hours using 24-hour clock. 00-24  (use "h" 0-24) mm = minutes. 00-59 ss = seconds. 00-59 k = time zone information yyyy = 4-digit year 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -