Class DateTimeConverter
Helper class to handler date time from and to local and utc.
Inheritance
Namespace: EPiServer.Data
Assembly: EPiServer.Data.dll
Version: 12.0.3Syntax
public abstract class DateTimeConverter : Object
Constructors
DateTimeConverter()
Declaration
protected DateTimeConverter()
Properties
MaxValue
Gets the highest value that can be saved.
Declaration
public static DateTime MaxValue { get; }
Property Value
Type | Description |
---|---|
System. |
The highest value that can be saved. |
Remarks
The highest value is currently 9999-12-31.
MinValue
Gets the lowest value that can be saved.
Declaration
public static DateTime MinValue { get; }
Property Value
Type | Description |
---|---|
System. |
The lowest value that can be saved. |
Remarks
The lowest value is currently 1753-01-01.
Methods
ParseToUtc(String)
Converts the specified string representation of a date and time to its System.
Declaration
public abstract DateTime ParseToUtc(string value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | A string containing a date and time to convert. |
Returns
Type | Description |
---|---|
System. |
An object that is equivalent to the date and time contained in |
Remarks
If a call to Date
Exceptions
Type | Condition |
---|---|
System. |
|
System. |
|
ParseToUtc(String, IFormatProvider)
Converts the specified string representation of a date and time to its System.
Declaration
public abstract DateTime ParseToUtc(string value, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | A string containing a date and time to convert. |
System. |
provider | An object that supplies culture-specific format information about |
Returns
Type | Description |
---|---|
System. |
An object that is equivalent to the date and time contained in s as specified by |
Remarks
If a call to Date
Exceptions
Type | Condition |
---|---|
System. |
|
System. |
|
ReadDatabaseValueAsLocal(Object)
Read an object returned from a database call to a Local Date
Declaration
public abstract Nullable<DateTime> ReadDatabaseValueAsLocal(object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | An object representing a Date |
Returns
Type | Description |
---|---|
System. |
The converted value, or null if value is null or equal to DBNull. |
ReadDatabaseValueAsUtc(Object)
Read an object returned from a database call to a UTC Date
Declaration
public abstract Nullable<DateTime> ReadDatabaseValueAsUtc(object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | An object representing a Date |
Returns
Type | Description |
---|---|
System. |
The converted value, or null if value is null or equal to DBNull. |
ToLocalTime(DateTime, Boolean)
Converts value
to local time.
Declaration
public abstract DateTime ToLocalTime(DateTime value, bool convertUnspecified)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The value to convert. |
System. |
convertUnspecified | If true, values with Date |
Returns
Type | Description |
---|---|
System. |
The possibly converted Date |
ToUniversalTime(DateTime, Boolean)
Converts value
to universal time.
Declaration
public abstract DateTime ToUniversalTime(DateTime value, bool convertUnspecified)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | The value to convert. |
System. |
convertUnspecified | If true, values with Date |
Returns
Type | Description |
---|---|
System. |
The possibly converted Date |
TryParseToUtc(String, out DateTime)
Converts the specified string representation of a date and time to its
System.
Declaration
public abstract bool TryParseToUtc(string value, out DateTime result)
Parameters
Type | Name | Description |
---|---|---|
System. |
value | A string containing a date and time to convert. |
System. |
result | When this method returns, contains the System. |
Returns
Type | Description |
---|---|
System. |
True if the |
Remarks
If a call to Date
Exceptions
Type | Condition |
---|---|
System. |
The date is in Japanese Emperor Year (Wareki) format and the year is out of range. |