pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <bdo id='89EmL'></bdo><ul id='89EmL'></ul>
  1. <i id='89EmL'><tr id='89EmL'><dt id='89EmL'><q id='89EmL'><span id='89EmL'><b id='89EmL'><form id='89EmL'><ins id='89EmL'></ins><ul id='89EmL'></ul><sub id='89EmL'></sub></form><legend id='89EmL'></legend><bdo id='89EmL'><pre id='89EmL'><center id='89EmL'></center></pre></bdo></b><th id='89EmL'></th></span></q></dt></tr></i><div class="ajs731l" id='89EmL'><tfoot id='89EmL'></tfoot><dl id='89EmL'><fieldset id='89EmL'></fieldset></dl></div>

    <small id='89EmL'></small><noframes id='89EmL'>

      <legend id='89EmL'><style id='89EmL'><dir id='89EmL'><q id='89EmL'></q></dir></style></legend>
    1. <tfoot id='89EmL'></tfoot>

      如何將 ISO8601 TimeSpan 轉換為 C# TimeSpan?

      How do I convert an ISO8601 TimeSpan to a C# TimeSpan?(如何將 ISO8601 TimeSpan 轉換為 C# TimeSpan?)
      <tfoot id='KbaCo'></tfoot>

        <i id='KbaCo'><tr id='KbaCo'><dt id='KbaCo'><q id='KbaCo'><span id='KbaCo'><b id='KbaCo'><form id='KbaCo'><ins id='KbaCo'></ins><ul id='KbaCo'></ul><sub id='KbaCo'></sub></form><legend id='KbaCo'></legend><bdo id='KbaCo'><pre id='KbaCo'><center id='KbaCo'></center></pre></bdo></b><th id='KbaCo'></th></span></q></dt></tr></i><div class="cn2mwxw" id='KbaCo'><tfoot id='KbaCo'></tfoot><dl id='KbaCo'><fieldset id='KbaCo'></fieldset></dl></div>
            <bdo id='KbaCo'></bdo><ul id='KbaCo'></ul>

                <tbody id='KbaCo'></tbody>
            1. <legend id='KbaCo'><style id='KbaCo'><dir id='KbaCo'><q id='KbaCo'></q></dir></style></legend>

              1. <small id='KbaCo'></small><noframes id='KbaCo'>

                本文介紹了如何將 ISO8601 TimeSpan 轉換為 C# TimeSpan?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                當我嘗試執行以下操作(例如)時,我得到了一個 System.FormatException:

                I am getting a System.FormatException when I try to do the following (as an example):

                TimeSpan ts = XmlConvert.ToTimeSpan("P72H");
                

                我調查了 ISO8601 標準,它似乎是正確的,但我無論我做什么,都無法讓它在不拋出異常的情況下解析時間.

                I've investigated the ISO8601 Standard and it seems to be correct, but I cannot get it to parse hours without throwing an exception, no matter what I do.

                謝謝!

                異常詳情:

                System.FormatException was unhandled by user code
                HResult=-2146233033
                Message=The string 'P72H' is not a valid TimeSpan value.
                Source=System.Xml
                

                推薦答案

                您需要在字符串中添加時間分隔符.試試這個:

                You need to add the Time separator to your string. Try this:

                TimeSpan ts = XmlConvert.ToTimeSpan("PT72H");
                

                查看持續時間規范 - http://www.w3.org/TR/xmlschema-2/#duration

                See the duration specification - http://www.w3.org/TR/xmlschema-2/#duration

                3.2.6.1 詞法表示
                持續時間的詞法表示是 [ISO 8601] 擴展格式 PnYn MnDTnH nMnS,其中 nY 表示年數,nM 表示月數,nD 表示天數,'T' 是日期/時間分隔符,nH 表示數字小時數,nM 分鐘數和 nS 秒數.秒數可以包含任意精度的十進制數字.

                3.2.6.1 Lexical representation
                The lexical representation for duration is the [ISO 8601] extended format PnYn MnDTnH nMnS, where nY represents the number of years, nM the number of months, nD the number of days, 'T' is the date/time separator, nH the number of hours, nM the number of minutes and nS the number of seconds. The number of seconds can include decimal digits to arbitrary precision.

                根據評論編輯/更新

                由于存在一些問題,為什么字符串 P2M2W5D 不會被視為有效的 TimeSpan,因為 W 是 ISO 8601 的一部分標準,我想添加此更新,以便如果有人遇到該問題,他們不必通讀評論即可獲得答案.對于有問題的原始字符串 P72HP2M2W5D 的問題是該字符串必須符合 W3C XML Schema(請參閱 XmlConvert.ToTimeSpan).當我們查看 W3C XML Schema(上面的鏈接)時,它引用了 ISO 8601 標準,特別是第 5.5.3.2.1 節,它給出了 W 不是有效字符的原因在 XML 架構中:

                As there was some question as to why the string P2M2W5D would not be considered a valid TimeSpan since W is part of the ISO 8601 standard, I wanted to add this update so that if someone runs across that issue they don't have to read through the comments to get the answer. The issue, both for the original string in question P72H and P2M2W5D is that the string must conform to the W3C XML Schema (see the documentation for XmlConvert.ToTimeSpan). When we look at the W3C XML Schema (link above), it references back to the ISO 8601 standard, and in particular to section 5.5.3.2.1 which gives the reason why W is not a valid character in the XML Schema:

                由于周沒有明確的結轉點(52 或 53),因此周應不能在這些應用程序中使用

                Since weeks have no defined carry-over point (52 or 53), weeks should not be used in these applications

                這篇關于如何將 ISO8601 TimeSpan 轉換為 C# TimeSpan?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Ignore whitespace while reading XML(讀取 XML 時忽略空格)
                XML to LINQ with Checking Null Elements(帶有檢查空元素的 XML 到 LINQ)
                Reading XML with unclosed tags in C#(在 C# 中讀取帶有未閉合標簽的 XML)
                Parsing tables, cells with Html agility in C#(在 C# 中使用 Html 敏捷性解析表格、單元格)
                delete element from xml using LINQ(使用 LINQ 從 xml 中刪除元素)
                Parse malformed XML(解析格式錯誤的 XML)

                  <small id='iG86P'></small><noframes id='iG86P'>

                  <i id='iG86P'><tr id='iG86P'><dt id='iG86P'><q id='iG86P'><span id='iG86P'><b id='iG86P'><form id='iG86P'><ins id='iG86P'></ins><ul id='iG86P'></ul><sub id='iG86P'></sub></form><legend id='iG86P'></legend><bdo id='iG86P'><pre id='iG86P'><center id='iG86P'></center></pre></bdo></b><th id='iG86P'></th></span></q></dt></tr></i><div class="wnblzmp" id='iG86P'><tfoot id='iG86P'></tfoot><dl id='iG86P'><fieldset id='iG86P'></fieldset></dl></div>
                    <tfoot id='iG86P'></tfoot>
                    • <legend id='iG86P'><style id='iG86P'><dir id='iG86P'><q id='iG86P'></q></dir></style></legend>
                          <tbody id='iG86P'></tbody>
                        • <bdo id='iG86P'></bdo><ul id='iG86P'></ul>
                          主站蜘蛛池模板: 翅片管散热器价格_钢制暖气片报价_钢制板式散热器厂家「河北冀春暖气片有限公司」 | 厚壁钢管-厚壁无缝钢管-小口径厚壁钢管-大口径厚壁钢管 - 聊城宽达钢管有限公司 | 进口便携式天平,外校_十万分之一分析天平,奥豪斯工业台秤,V2000防水秤-重庆珂偌德科技有限公司(www.crdkj.com) | 智能交通网_智能交通系统_ITS_交通监控_卫星导航_智能交通行业 | 法钢特种钢材(上海)有限公司 - 耐磨钢板、高强度钢板销售加工 阀门智能定位器_电液动执行器_气动执行机构-赫尔法流体技术(北京)有限公司 | 防勒索软件_数据防泄密_Trellix(原McAfee)核心代理商_Trellix(原Fireeye)售后-广州文智信息科技有限公司 | 展厅设计-展馆设计-专业企业展厅展馆设计公司-昆明华文创意 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-沼河浸过滤器 | 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 双效节能浓缩器-热回流提取浓缩机组-温州市利宏机械 | 液晶拼接屏厂家_拼接屏品牌_拼接屏价格_监控大屏—北京维康 | 蓄电池回收,ups电池后备电源回收,铅酸蓄电池回收,机房电源回收-广州益夫铅酸电池回收公司 | 波纹补偿器_不锈钢波纹补偿器_巩义市润达管道设备制造有限公司 | 食品级焦亚硫酸钠_工业级焦亚硫酸钠_焦亚硫酸钠-潍坊邦华化工有限公司 | 市政路灯_厂家-淄博信达电力科技有限公司 | 喷砂机厂家_自动喷砂机生产_新瑞自动化喷砂除锈设备 | 吨袋包装机|吨包秤|吨包机|集装袋包装机-烟台华恩科技 | 活性氧化铝球|氧化铝干燥剂|分子筛干燥剂|氢氧化铝粉-淄博同心材料有限公司 | 水质传感器_水质监测站_雨量监测站_水文监测站-山东水境传感科技有限公司 | 珠海白蚁防治_珠海灭鼠_珠海杀虫灭鼠_珠海灭蟑螂_珠海酒店消杀_珠海工厂杀虫灭鼠_立净虫控防治服务有限公司 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 偏心半球阀-电动偏心半球阀-调流调压阀-旋球阀-上欧阀门有限公司 | 肉嫩度仪-凝胶测试仪-国产质构仪-气味分析仪-上海保圣实业发展有限公司|总部 | 交变/复合盐雾试验箱-高低温冲击试验箱_安奈设备产品供应杭州/江苏南京/安徽马鞍山合肥等全国各地 | 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | 螺钉式热电偶_便携式温度传感器_压簧式热电偶|无锡联泰仪表有限公司|首页 | 工业雾炮机_超细雾炮_远程抑尘射雾器-世纪润德环保设备 | 「安徽双凯」自动售货机-无人售货机-成人用品-自动饮料食品零食售货机 | 橡胶膜片,夹布膜片,橡胶隔膜密封,泵阀设备密封膜片-衡水汉丰橡塑科技公司网站 | 制氮设备_PSA制氮机_激光切割制氮机_氮气机生产厂家-苏州西斯气体设备有限公司 | 岩棉板|岩棉复合板|聚氨酯夹芯板|岩棉夹芯板|彩钢夹芯板-江苏恒海钢结构 | 合肥宠物店装修_合肥宠物美容院装修_合肥宠物医院设计装修公司-安徽盛世和居装饰 | 顺辉瓷砖-大国品牌-中国顺辉 | 冷水机,风冷冷水机,水冷冷水机,螺杆冷水机专业制造商-上海祝松机械有限公司 | 重庆LED显示屏_显示屏安装公司_重庆LED显示屏批发-彩光科技公司 重庆钣金加工厂家首页-专业定做监控电视墙_操作台 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 电车线(用于供电给电车的输电线路)-百科 | 施工电梯_齿条货梯_烟囱电梯_物料提升机-河南大诚机械制造有限公司 | 窖井盖锯圆机_锯圆机金刚石锯片-无锡茂达金刚石有限公司 | PVC地板|PVC塑胶地板|PVC地板厂家|地板胶|防静电地板-无锡腾方装饰材料有限公司-咨询热线:4008-798-128 | 冷藏车-东风吸污车-纯电动环卫车-污水净化车-应急特勤保障车-程力专汽厂家-程力专用汽车股份有限公司销售二十一分公司 |