1

VisualStudio2008のXSDツールによって自動生成されたクラスがあります。このクラスは次のようになります。

/// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.xxx.com")]
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.xxx.com", IsNullable = false)]
    public partial class Invoice
    {

        private DateTime startDateField;

      // Some other fields goes here.

             /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute()]
        public System.DateTime startDate
        {
            get
            {
                return this. startDateField;
            }
            set
            {
                this. startDateField = value;
            }
        }
   }

Invoiceのインスタンスをシリアル化すると、次のようなxmlが表示されます。

<?xml version="1.0" encoding="utf-8"?>
<Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xxx.com http://www.xxx/cfdv22.xsd"  startDate ="2012-09-27T16:41:36-07:00">
… some other elements goes here.
</Invoice>

属性の値が表示されている場合、startDateには最後にタイムゾーンが含まれています。

日時オブジェクトをこのyyyy-MM-ddTHH:mm:ssのような表現に変換する、実現中に何かを特定する方法はありますか?または、タイムゾーンを削除するものですか?

前もって感謝します。

4

1 に答える 1

1

XMLの「datetime」タイプは、 XML Schema Recomendationに従って、 ISO8601の日付です。

タイムゾーンを気にしない場合は、「日付」データ型がおそらく必要なものです。

于 2012-09-28T00:57:54.430 に答える