Altova.Types.DateTime
This class enables you to process XML attributes or elements that have date and time types, such as xs:dateTime.
Constructors
Name | Description | |
---|---|---|
DateTime(DateTime obj) | Initializes a new instance of the DateTime class to the DateTime object supplied as argument. | |
DateTime(System.DateTime newvalue) | Initializes a new instance of the DateTime class to the System.DateTime object supplied as argument. | |
DateTime(int year, int month, int day, int hour, int minute, double second, int offsetTZ) | Initializes a new instance of the DateTime class to the year, month, day, hour, minute, second, and timezone offset supplied as arguments. | |
DateTime(int year, int month, int day, int hour, int minute, double second) | Initializes a new instance of the DateTime class to the year, month, day, hour, minute, and second supplied as arguments. | |
DateTime(int year, int month, int day) | Initializes a new instance of the DateTime class to the year, month and day supplied as arguments. |
Properties
Name | Description | |
---|---|---|
bool HasTimezone | Gets a Boolean value which indicates if the DateTime has a timezone. | |
static DateTime Now | Gets a DateTime object that is set to the current date and time on this computer. | |
short TimezoneOffset | Gets or sets the timezone offset, in minutes, of the DateTime object. | |
System.DateTime Value | Gets or sets the value of the DateTime object as a System.DateTime value. |
Methods
Name | Description | |
---|---|---|
int CompareTo(object obj) | The DateTime class implements the IComparable interface. This method compares the current instance of DateTime to another object and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. See also https://msdn.microsoft.com/en-us/library/system.icomparable.compareto(v=vs.110).aspx | |
override bool Equals(object obj) | Returns true if the specified object is equal to the current object; false otherwise. | |
System.DateTime GetDateTime(bool correctTZ) | Returns a System.DateTime object from the current Altova.Types.DateTime instance. The correctTZ Boolean argument specifies whether the time of the returned object must be adjusted according to the timezone of the current Altova.Types.DateTime instance. | |
override int GetHashCode() | Returns the hash code of the current instance. | |
int GetWeekOfMonth() | Returns the number of the week in month as an integer. | |
static DateTime Parse( string s ) | Creates a DateTime object from the string supplied as argument. For example, the following sample string values would be converted successfully to a DateTime object:
2015-01-01T23:23:23 2015-01-01 2015-11 23:23:23
An exception is raised if the string cannot be converted to a DateTime object. | |
static DateTime Parse(string s, DateTimeFormat format) | Creates a DateTime object from a string, using the format supplied as argument. For the list of possible formats, see Altova.Types.DateTimeFormat.
An exception is raised if the string cannot be converted to a DateTime object. | |
override string ToString() | Converts the DateTime object to a string. | |
string ToString(DateTimeFormat format) | Converts the DateTime object to a string, using the format supplied as argument. For the list of possible formats, see Altova.Types.DateTimeFormat. |
Operators
Name | Description |
---|---|
!= | Determines if DateTime a is not equal to DateTime b. |
< | Determines if DateTime a is less than DateTime b. |
<= | Determines if DateTime a is less than or equal to DateTime b. |
== | Determines if DateTime a is equal to DateTime b. |
> | Determines if DateTime a is greater than DateTime b. |
>= | Determines if DateTime a is greater than or equal to DateTime b. |
Examples
Before using the following code listings in your program, ensure the Altova types are imported:
using Altova.Types; |
The following code listing illustrates various ways to create DateTime objects:
protected static void DateTimeExample1() |
The following code listing illustrates various ways to format DateTime objects:
protected static void DateTimeExample2() |