首页 新闻 会员 周边 捐助

夏令时 的 时间转换

0
悬赏园豆:200 [待解决问题]

时区为 Venezuela Standard Time(-4:30)传回的时间如下

2016-04-20T06:02:13-04:4294967266

如何传成时间对象,直接convert会报错

未处理System.FormatException HResult=-2146233033 Message=String was not recognized as a valid DateTime. Source=mscorlib StackTrace: at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s) at InternalCrm.Test.TestTimeZone.Run() in c:Program.cs:line 82 at InternalCrm.Test.Program.Main(String[] args) in c:\Program.cs:line 198 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

boron lin的主页 boron lin | 初学一级 | 园豆:2
提问于:2016-04-21 11:47
< >
分享
所有回答(2)
1

string s = "2016-04-20T06:02:13-04:4294967266";

string fff = s.Substring(s.LastIndexOf(':') + 1);
s = s.Substring(0, s.LastIndexOf(':'));
s = s.Insert(19, "." + fff + " ");

DateTime d = DateTime.Parse(s);

刘宏玺 | 园豆:14020 (专家六级) | 2016-04-21 13:19

这个做会少了30分错, 

直接把  4294967266 替成30也是可以的,只是这样做看起来并不友好

支持(0) 反对(0) boron lin | 园豆:2 (初学一级) | 2016-04-21 13:30

@boron lin: 我还以为4294967266是毫秒呢

支持(0) 反对(0) 刘宏玺 | 园豆:14020 (专家六级) | 2016-04-21 13:32
0

04:4294967266 保留到秒 四舍五入就可以了

Yu | 园豆:12990 (专家六级) | 2016-04-21 13:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册