Overview | Package | Class | Tree | Deprecated | Index | Help
| XCC/J 4.2-9
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.marklogic.xcc.types
Class Duration

    java.lang.Object
      com.marklogic.xcc.types.Duration

All Implemented Interfaces:
  XdmDuration

    public class Duration

extends Object
implements XdmDuration

The Duration class is a mutable class which implements the XdmDuration interface.

Constructor Summary
`Duration()` Construct a duration object, initialized to zero length.
`Duration(boolean negative, int years, int months, int days, int hours, int minutes, BigDecimal seconds)` Construct a duration object by specifying the individual values.
`Duration(String duration)` Construct a duration object initialized from the given string in the format of a serialized xs:duration item.

Method Summary
`boolean` | `equals(Object otherObj)` Compares this `XdmDuration` object to the specified object.
`int` | `getDays()`
`int` | `getHours()`
`int` | `getMinutes()`
`int` | `getMonths()`
`BigDecimal` | `getSeconds()`
`long` | `getWholeSeconds()`
`int` | `getYears()`
`int` | `hashCode()`
`boolean` | `isNegative()`
`boolean` | `isPositive()`
`void` | `setDays(int days)` Sets the days value of this duration.
`void` | `setHours(int hours)` Sets the hours value of this duration.
`void` | `setMinutes(int minutes)` Sets the minutes value of this duration.
`void` | `setMonths(int months)` Sets the months value of this duration.
`void` | `setSign(boolean negative)` Sets the sign of this duration, either positive or negative.
`void` | `setWholeSeconds(long seconds)` Sets the seconds value of this duration.
`void` | `setYears(int years)` Sets the years value of this duration.
`String` | `toString()` Formats this duration object as a String in the format prescribed in the W3C description of XML datatypes for a duration.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Duration

    public Duration()

  Construct a duration object, initialized to zero length.

### Duration

    public Duration(String duration)

  Construct a duration object initialized from the given string in the format of a serialized xs:duration item. Examples: P2Y3M141DT12H46M12.34S, -P92M, -P32M2DT0.2S.

  Parameters:
    `duration` - An xs:duration value as defined by IllegalArgumentException - If the given string is not a valid duration value.

### Duration

    public Duration(boolean negative,
                    int years,
                    int months,
                    int days,
                    int hours,
                    int minutes,
                    BigDecimal seconds)

  Construct a duration object by specifying the individual values.

  Parameters:
    `negative` - Pass true if the duration should be neagtive, otherwise false.
    `years` - The number of years.
    `months` - The number of months.
    `days` - The number of days.
    `hours` - The number of hours.
    `minutes` - The number of minutes.
    `seconds` - The (possibly fractional) number of seconds. Note that this is specified by a `BigDecimal` object. If null, a value of zero is assumed.

Method Detail

### isPositive

    public boolean isPositive()

  Specified by:
    `isPositive` in interface `XdmDuration`

### isNegative

    public boolean isNegative()

  Specified by:
    `isNegative` in interface `XdmDuration`

### getYears

    public int getYears()

  Specified by:
    `getYears` in interface `XdmDuration`

### getMonths

    public int getMonths()

  Specified by:
    `getMonths` in interface `XdmDuration`

### getDays

    public int getDays()

  Specified by:
    `getDays` in interface `XdmDuration`

### getHours

    public int getHours()

  Specified by:
    `getHours` in interface `XdmDuration`

### getMinutes

    public int getMinutes()

  Specified by:
    `getMinutes` in interface `XdmDuration`

### getWholeSeconds

    public long getWholeSeconds()

  Specified by:
    `getWholeSeconds` in interface `XdmDuration`

### getSeconds

    public BigDecimal getSeconds()

  Specified by:
    `getSeconds` in interface `XdmDuration`

### setSign

    public void setSign(boolean negative)

  Sets the sign of this duration, either positive or negative.

  Parameters:
    `negative` - If true, the duration is considered negative, otherwise it's positive.

### setYears

    public void setYears(int years)

  Sets the years value of this duration.

  Parameters:
    `years` - the integer years value.

### setMonths

    public void setMonths(int months)

  Sets the months value of this duration.

  Parameters:
    `months` - the integer months value.

### setDays

    public void setDays(int days)

  Sets the days value of this duration.

  Parameters:
    `days` - the integer days value.

### setHours

    public void setHours(int hours)

  Sets the hours value of this duration.

  Parameters:
    `hours` - the integer hours value.

### setMinutes

    public void setMinutes(int minutes)

  Sets the minutes value of this duration.

  Parameters:
    `minutes` - the integer minutes value.

### setWholeSeconds

    public void setWholeSeconds(long seconds)

  Sets the seconds value of this duration.

  Parameters:
    `seconds` - the integer seconds value.

### equals

    public boolean equals(Object otherObj)

  Compares this `XdmDuration` object to the specified object. The result is true if and only if the argument is not null and the sign, year, month, day, hours, minutes, seconds and subseconds values have the same value as this object.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `otherObj` - the Duration object to compare
  Returns:
    true if the objects have the same duration value, false otherwise.

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Formats this duration object as a String in the format prescribed in the W3C description of XML datatypes for a duration.

  Example: -P2Y4M5DT3H5M42.057S

  Represents a duration of minus 2 years, 4 months, 5 days, 3 hours, 5 minutes, and 42.057 seconds.

  Overrides:
    `toString` in class `Object`
  Returns:
    the String representation of the duration value.
  See Also:

    Overview | Package | Class | Tree | Deprecated | Index | Help
    | XCC/J 4.2-9
    PREV CLASS NEXT CLASS | FRAMES NO FRAMES
    SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

    Copyright © 2003-2012 MarkLogic Corporation, All Rights Reserved.

    Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com