为什么我在Mono上得到了这个错误,但在Windows上却没有?
Unhandled Exception: System.FormatException: Invalid format string
at System.DateTime.ParseExact (string,string[],System.IFormatProvider,System.Glo balization.DateTimeStyles) <0x00127>
at System.DateTime.ParseExact (string,string,System.IFormatProvider,System.Globa lization.DateTimeStyles) <0x0004f>
at System.DateTime.ParseExact (string,string,System.IFormatProvider) <0x0001f>
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServi ces.Closure,System.Runtime.CompilerServices.CallSite,System.Type,object,string,S ystem.Globalization.DateTimeFormatInfo) <0x000f3>
at System.Dynamic.UpdateDelegates.UpdateAndExecute4<System.Type, object, string, System.Globalization.DateTimeFormatInfo, object> (System.Runtime.CompilerServic es.CallSite,System.Type,object,string,System.Globalization.DateTimeFormatInfo) < 0x00418>
at TwitterScraper.Program.scrapeTwitter () <0x00a22>
at TwitterScraper.Program.Main (string[]) <0x000bf>在这里使用以下代码
DateTime tweettime = DateTime.ParseExact(obj["created_at"].ToString(),
"ddd MMM dd HH:mm:ss %K yyyy",
CultureInfo.InvariantCulture.DateTimeFormat);这是用来处理Twitter给你的时间格式的。
发布于 2013-09-19 22:04:33
试着这样做:
DateTimeOffset tweettime = DateTimeOffset.ParseExact(yourInputString,
"ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);https://stackoverflow.com/questions/15535634
复制相似问题