This class enables you to process XML attributes or elements of type xs:duration.
Name |
Description |
|
---|---|---|
![]() |
Duration(Duration newvalue) |
Initializes a new instance of the Duration class to the Duration object supplied as argument. |
![]() |
Duration(int newyear, int newmonth, int newday, int newhour, int newminute, int newsecond, double newpartsecond, boolean newisnegative) |
Initializes a new instance of the Duration class to a duration built from parts supplied as arguments. |
Name |
Description |
|||||||
---|---|---|---|---|---|---|---|---|
![]() |
static Duration getFromDayTime( int newday, int newhour, int newminute, int newsecond, double newpartsecond ) |
Returns a Duration object created from the number of days, hours, minutes, seconds, and fractional second parts supplied as argument. |
||||||
![]() |
static Duration getFromYearMonth( int newyear, int newmonth ) |
Returns a Duration object created from the number of years and months supplied as argument. |
||||||
![]() |
static Duration parse( String s ) |
Returns a Duration object created from the string supplied as argument. For example, the string -P1Y1M1DT1H1M1.333S can be used to create a negative duration of one year, one month, one day, one hour, one minute, one second, and 0.333 fractional parts of a second. To create a negative duration, append the minus sign ( - ) to the string. |
||||||
![]() |
static Duration parse( String s, ParseType pt ) |
Returns a Duration object created from the string supplied as argument, using a specific parse format. The parse format can be any of the following:
|
||||||
![]() |
int getDay() |
Returns the number of days in the current Duration instance. |
||||||
![]() |
long getDayTimeValue() |
Returns the day and time value (in milliseconds) of the current Duration instance. Years and months are ignored. |
||||||
![]() |
int getHour() |
Returns the number of hours in the current Duration instance. |
||||||
![]() |
int getMillisecond() |
Returns the number of milliseconds in the current Duration instance. |
||||||
![]() |
int getMinute() |
Returns the number of minutes in the current Duration instance. |
||||||
![]() |
int getMonth() |
Returns the number of months in the current Duration instance. |
||||||
![]() |
double getPartSecond() |
Returns the number of fractional second parts in the current Duration instance. |
||||||
![]() |
int getSecond() |
Returns the number of seconds in the current Duration instance. |
||||||
![]() |
int getYear() |
Returns the number of years in the current Duration instance. |
||||||
![]() |
int getYearMonthValue() |
Returns the year and month value (in months) of the current Duration instance. Days, hours, seconds, and milliseconds are ignored. |
||||||
![]() |
boolean isNegative() |
Returns Boolean true if the current Duration instance is negative. |
||||||
![]() |
void setDayTimeValue(long l) |
Sets the duration to the number of milliseconds supplied as argument, affecting only the day and time part of the duration. |
||||||
![]() |
void setNegative( boolean isnegative ) |
Converts the current Duration instance to a negative duration. |
||||||
![]() |
void setYearMonthValue(int l) |
Sets the duration to the number of months supplied as argument. Only the years and months part of the duration is affected. |
||||||
![]() |
String toString() |
Returns the string representation of the current Duration instance, for example:
-P4DT4H4M4.774S |
||||||
![]() |
String toYearMonthString() |
Returns the string representation of the YearMonth part of the current Duration instance, for example:
P1Y2M |
Before using the following code listings in your program, ensure the Altova types are imported:
import com.altova.types.*; |
The following code listing illustrates various ways to create Duration objects:
protected static void ExampleDuration() |
The following code listing illustrates getting and setting the value of Duration objects:
protected static void DurationExample2() |