Altova.Types.Duration
This class enables you to process XML attributes or elements of type xs:duration.
Constructors
Name | Description | |
---|---|---|
Duration(Duration obj) | Initializes a new instance of the Duration class to the Duration object supplied as argument. | |
Duration(System.TimeSpan newvalue) | Initializes a new instance of the Duration class to the System.TimeSpan object supplied as argument. | |
Duration(long ticks) | Initializes a new instance of the Duration class to the number of ticks supplied as argument. | |
Duration(int newyears, int newmonths, int days, int hours, int minutes, int seconds, double partseconds, bool bnegative) | Initializes a new instance of the Duration class to a duration built from parts supplied as arguments. |
Properties
Name | Description | |
---|---|---|
int Months | Gets or sets the number of months of the current instance of Duration. | |
System.TimeSpan Value | Gets or sets the value (as System.TimeSpan) of the current instance of Duration. | |
int Years | Gets or sets the number of years of the current instance of Duration. |
Methods
Name | Description | |||||||
---|---|---|---|---|---|---|---|---|
override bool Equals(object other) | Returns true if the specified object is equal to the current object; false otherwise. | |||||||
override int GetHashCode() | Returns the hash code of the current instance. | |||||||
bool IsNegative() | Returns true if the current instance of Duration represents a negative duration. | |||||||
static Duration Parse( string s, ParseType pt ) | Returns an Altova.Types.Duration object parsed from the string supplied as argument, using the parse type supplied as argument. Valid parse type values:
Note that this method is static and can only be called on the class itself, not on an instance of the class. | |||||||
override string ToString() | Converts the current Duration instance to string. For example, a time span of 3 hours, 4 minutes, and 5 seconds would be converted to "PT3H4M5S". | |||||||
string ToYearMonthString() | Converts the current Duration instance to string, using the "Year and Month" parse type. |
Operators
Name | Description |
---|---|
!= | Determines if Duration a is not equal to Duration b. |
== | Determines if Duration a is equal to Duration 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 Duration objects:
protected static void DurationExample1() |
The following code listing illustrates getting values from Duration objects:
protected static void DurationExample2() |