xpo-devexpress-dot-xpo-dot-metadata-3632642d.md
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
public class UtcDateTimeConverter :
ValueConverter
Public Class UtcDateTimeConverter
Inherits ValueConverter
For more information on converters, see the ValueConverter class description.
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.
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); }
}
}
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
Object ValueConverter UtcDateTimeConverter
See Also