VB.Net XML序列化中格式化日期

来源:互联网 发布:电子商务发展数据2016 编辑:程序博客网 时间:2024/03/28 22:56
<Serializable><XmlRoot(ElementName := "Root">Property ID As Integer        Property Code As String        Property Name As String        Property Description As String        Property Comments As String        Property Pinyin As String        Property Aliases As New XmlDocument        Property OrderNo As Integer        '序列化时忽略此属性        <XmlIgnore>            Property ActFrom As Date        '序列化时该属性序列化为"ActFrom"节点        <XmlElement(ElementName:="ActFrom")>        Property FormatActFrom As String            Get                Return ActFrom.ToString("yyyy-MM-dd HH:mm")            End Get            Set(value As String)                ActFrom = Date.Parse(value)            End Set        End Property        <XmlIgnore>        Property ActTo As Date        <XmlElement(ElementName:="ActTo")>        Property FormatActTo As String            Get                Return ActTo.ToString("yyyy-MM-dd HH:mm")            End Get            Set(value As String)                ActTo = Date.Parse(value)            End Set        End Property        ReadOnly Property Active As Boolean            Get                Return Date.Now >= ActFrom And Date.Now <= ActTo            End Get        End Property        Public Sub New()        End SubEnd Class
原创粉丝点击