Package com.oss.asn1

Class ISO8601Duration

All Implemented Interfaces:
com.oss.asn1.Comparable, ISO8601TimeInterface, Serializable, Cloneable

public class ISO8601Duration extends AbstractISO8601Time
The ISO8601Duration class represents the ASN.1 DURATION type.
Since:
ASN.1/Java 4.0 Beta A
See Also:
  • Constructor Details

    • ISO8601Duration

      public ISO8601Duration()
      The default constructor.
    • ISO8601Duration

      public ISO8601Duration(String value) throws BadTimeFormatException
      Constructs duration value from a string. String should be in the following basic format, "PnnYnnMnnDTnnHnnMnnS" or "PnnW" where nn is a one or more digit integer, which specifies an amount of years, months, weeks, days, hours, minutes or seconds depending on a designator which follows the "nn": Y,M,W,D,H,M or S. For reduced accuracy or decimal fraction representation any of the lowest order components may be omitted, decimal point with fractional value can be included into the lowest order component and zero valued components may be omitted. For example: "PT1.5H" represents one and a half an hour duration.
      Parameters:
      value - a string containing time of day value.
      Throws:
      BadTimeFormatException - if value has invalid format.
    • ISO8601Duration

      public ISO8601Duration(int years, int months, int days, int hours, int minutes, int seconds, ISO8601Duration.Fractional_part fractional_part)
      Constructs duration value from years, months, days, hour, minutes, seconds and fractional part components.
      Parameters:
      years - years value
      months - months value
      days - days value
      hours - hours value
      minutes - minutes value
      seconds - seconds value
      fractional_part - fractional part value
    • ISO8601Duration

      public ISO8601Duration(int weeks, ISO8601Duration.Fractional_part fractional_part)
      Constructs duration value weeks and fractional part components.
      Parameters:
      weeks - weeks value
      fractional_part - fractional part value
  • Method Details

    • setValue

      public void setValue(String value) throws BadTimeFormatException
      Set an instance of this class from a String containing value notation of the DURATION.
      Specified by:
      setValue in class AbstractISO8601Time
      Parameters:
      value - a string containing duration value.
      Throws:
      BadTimeFormatException - if value has invalid format
    • getYears

      public final int getYears()
      Get the years component of 'this' object.
      Returns:
      int value indicating the years.
    • getMonths

      public final int getMonths()
      Get the months component of 'this' object.
      Returns:
      int value indicating the months.
    • getWeeks

      public final int getWeeks()
      Get the weeks component of 'this' object.
      Returns:
      int value indicating the weeks.
    • getDays

      public final int getDays()
      Get the days component of 'this' object.
      Returns:
      int value indicating the days.
    • getHours

      public final int getHours()
      Get the hours component of 'this' object.
      Returns:
      int value indicating the hours.
    • getMinutes

      public final int getMinutes()
      Get the minutes component of 'this' object.
      Returns:
      int value indicating the minutes.
    • getSeconds

      public final int getSeconds()
      Get the seconds component of 'this' object.
      Returns:
      int value indicating the seconds.
    • getFractional_part

      public final ISO8601Duration.Fractional_part getFractional_part()
      Get the fractional part component of 'this' object.
      Returns:
      fractional part.
    • setYears

      public final void setYears(int years)
      Set the years component of 'this' object.
      Parameters:
      years - the years to set.
    • setMonths

      public final void setMonths(int months)
      Set the months component of 'this' object.
      Parameters:
      months - the months to set.
    • setWeeks

      public final void setWeeks(int weeks)
      Set the weeks component of 'this' object.
      Parameters:
      weeks - the weeks to set.
    • setDays

      public final void setDays(int days)
      Set the days component of 'this' object.
      Parameters:
      days - the days to set.
    • setHours

      public final void setHours(int hours)
      Set the hours component of 'this' object.
      Parameters:
      hours - the hours to set.
    • setMinutes

      public final void setMinutes(int minutes)
      Set the minutes component of 'this' object.
      Parameters:
      minutes - the minutes to set.
    • setSeconds

      public final void setSeconds(int seconds)
      Set the seconds component of 'this' object.
      Parameters:
      seconds - the seconds to set.
    • setFractional_part

      public final void setFractional_part(ISO8601Duration.Fractional_part fractional_part)
      Set the fractional part component of 'this' object.
      Parameters:
      fractional_part - the fractional part to set.
    • get

      public int get(int field)
      Get a field's value.
      Parameters:
      field - field designator.
      Returns:
      field's value.
    • set

      public void set(int field, int value)
      Set a field's value.
      Parameters:
      field - field designator.
      value - field value.
    • clear

      public void clear()
      Clears all the fields so they are set to UNDEFINED value.
    • equalTo

      public final boolean equalTo(ISO8601Duration that)
      Compare 'this' object to another ISO8601Duration object to see if their contents are the same.
      Parameters:
      that - the ISO8601Duration object to compare 'this' object to.
      Returns:
      true if contents of both objects are the same.
    • clone

      public Object clone()
      Clone 'this' object.
      Overrides:
      clone in class AbstractData
      Returns:
      deep copy of 'this' object.