Back to Devexpress

UtcDateTimeConverter Class

xpo-devexpress-dot-xpo-dot-metadata-3632642d.md

latest2.3 KB
Original Source

UtcDateTimeConverter Class

Represents a converter which can be used to convert DateTime objects from the local time to the current coordinated universal time (UTC).

Namespace : DevExpress.Xpo.Metadata

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public class UtcDateTimeConverter :
    ValueConverter
vb
Public Class UtcDateTimeConverter
    Inherits ValueConverter

Remarks

For more information on converters, see the ValueConverter class description.

Example

The following example shows how to convert the value of the Date property from the local time to the current coordinated universal time (UTC) when persisting it in a data store.

csharp
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
// ...
public class SampleUtc : XPObject {
    private DateTime date;
    [ValueConverter(typeof(UtcDateTimeConverter))]
    public DateTime Date {
        get { return date; }
        set { SetPropertyValue(nameof(Date), ref date, value); }
    }
}
vb
Imports DevExpress.Xpo
Imports DevExpress.Xpo.Metadata
' ...
Class SampleUtc
   Inherits XPObject
   Private _date As DateTime
   <ValueConverter(GetType(UtcDateTimeConverter))> _
   Public Property tDate() As DateTime
      Get
         Return _date
      End Get
      Set(ByVal Value As DateTime)
         SetPropertyValue(NameOf(Date), _date, Value)
      End Set
   End Property
End Class

Inheritance

Object ValueConverter UtcDateTimeConverter

See Also

UtcDateTimeConverter Members

ValueConverterAttribute

DevExpress.Xpo.Metadata Namespace