解析一个复杂的字符串作为DateTime [英] Parsing a complicated string as DateTime

查看:96
本文介绍了解析一个复杂的字符串作为DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何将以下格式转换成适当的 DateTime 对象?

  2011年10月19日(星期三)上午11:50:46 


解决方案

  string s =2011年10月19日,星期三11:50:46; 
DateTime dateTime = DateTime.ParseExact(s,
hh:mm:ss tt on dddd,MMMM dd,yyyy,CultureInfo.InvariantCulture);


Can someone tell me how should I approach converting the following format to a proper DateTime object?

11:50:46 AM on Wednesday, October 19, 2011

解决方案

        string s = "11:50:46 AM on Wednesday, October 19, 2011";
        DateTime dateTime = DateTime.ParseExact(s, 
            "hh:mm:ss tt on dddd, MMMM dd, yyyy", CultureInfo.InvariantCulture);

这篇关于解析一个复杂的字符串作为DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆