<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    http://www.tkk7.com/ebecket 返還網
    隨筆-140  評論-11  文章-131  trackbacks-0

    C# Use DateTime.ParseExact() instead of DateTime.Parse()

    I didn’t notice this until today, the DateTime I retrieve from my database has the format of yyyy/MM/dd hh:mm:ss.fff

    and if I use DateTime.Parse(), the .fff value will be lost.

    After searching google, I find out that not only DateTime.Parse() has this one problem, it also has problem with culture setting.

    So, whenever you what to parse a DateTime, use DateTime.ParseExact().

    Here is an useful example :

    string[] DateTimeList = {
    "yyyy/M/d tt hh:mm:ss",
    "yyyy/MM/dd tt hh:mm:ss",
    "yyyy/MM/dd HH:mm:ss",
    "yyyy/M/d HH:mm:ss",
    "yyyy/M/d",
    "yyyy/MM/dd"
    }; 
    DateTime dt = DateTime.ParseExact(" 2008/  3/18   PM 02: 50:23  ",
    DateTimeList,CultureInfo.InvariantCulture,
    DateTimeStyles.AllowWhiteSpaces
    );

    Remember, CultureInfo is important to parsing, for example tt in Chinese will be 上午/下午, in en-US will be AM/PM. You can use CultureInfo.CreateSpecificCulture() to create the culture you need.
    A small pattern reference

    yyyy year ‘2009′
    MM month ‘04′
    dd day ‘17′
    HH 24 hour ‘23′
    hh 12 hour ‘11′
    mm minutes ‘59′
    ss seconds ‘30′
    tt AM/PM
    zzz GMT
    posted on 2009-11-20 17:00 becket_zheng 閱讀(1864) 評論(0)  編輯  收藏 所屬分類: C#
    主站蜘蛛池模板: 国产做床爱无遮挡免费视频| 国产免费久久精品丫丫| 国产精品免费观看| 中文字幕亚洲综合久久| 免费人成在线观看网站品爱网| 亚洲成AV人片在线观看无| 精品一区二区三区高清免费观看 | 久久99国产亚洲精品观看| 国产一级婬片A视频免费观看| 亚洲日韩人妻第一页| 国产成人自产拍免费视频| 亚洲色WWW成人永久网址| 久久久久免费精品国产| 亚洲视频免费播放| 国产在线国偷精品产拍免费| 亚洲Aⅴ在线无码播放毛片一线天 亚洲avav天堂av在线网毛片 | 免费一级毛suv好看的国产网站 | 久久99青青精品免费观看| 久久久亚洲欧洲日产国码二区| 免费看片在线观看| 亚洲а∨天堂久久精品9966| 在线免费观看国产视频| 一级特黄录像视频免费| 久久国产亚洲观看| 无人在线观看免费高清视频| 青青青亚洲精品国产| 337p日本欧洲亚洲大胆裸体艺术 | 久久亚洲精品国产精品| 日韩精品成人无码专区免费| 偷自拍亚洲视频在线观看99| 亚洲精品国产成人片| ww4545四虎永久免费地址| 国产精品亚洲综合一区在线观看| 亚洲欧洲一区二区三区| 8090在线观看免费观看| 亚洲av无码专区在线观看下载| 亚洲午夜久久久久妓女影院| 67194国产精品免费观看| 色网站在线免费观看| 在线观看亚洲人成网站| 免费一级毛片不卡不收费|