Package com.oss.asn1

Class ISO8601Date

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

public class ISO8601Date extends AbstractISO8601Time
The ISO8601Date class represents the ASN.1 DATE type
Since:
ASN.1/Java 6.0
See Also:
  • Constructor Details

    • ISO8601Date

      public ISO8601Date()
      The default constructor.
    • ISO8601Date

      public ISO8601Date(String value) throws BadTimeFormatException
      Constructs date value from a string. String should be in the "YYYY-MM-DD" format, where YYYY is a four-digit year, MM is a two-digit month and DD is a two-digit day number.
      Parameters:
      value - a string containing date value.
      Throws:
      BadTimeFormatException - if value has invalid format.
    • ISO8601Date

      public ISO8601Date(int year, int month, int day)
      Constructs date value from year, month and day components.
      Parameters:
      year - year value
      month - month value
      day - day value
  • Method Details

    • clone

      public ISO8601Date clone()
      Clone 'this' object.
      Returns:
      deep copy of 'this' object.
    • setValue

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

      public final int getYear()
      Get the year component of 'this' object.
      Returns:
      int value indicating the year.
    • getMonth

      public final int getMonth()
      Get the month component of 'this' object.
      Returns:
      int value indicating the month.
    • getDay

      public final int getDay()
      Get the day component of 'this' object.
      Returns:
      int value indicating the day.
    • setYear

      public final void setYear(int year)
      Set the year component of 'this' object.
      Parameters:
      year - the year to set.
    • setMonth

      public final void setMonth(int month)
      Set the month component of 'this' object.
      Parameters:
      month - the month to set.
    • setDay

      public final void setDay(int day)
      Set the day component of 'this' object.
      Parameters:
      day - the day to set.
    • get

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

      public void set(int field, int value)
      Set field 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(ISO8601Date that)
      Compare 'this' object to another ISO8601Date object to see if their contents are the same.
      Parameters:
      that - the ISO8601Date object to compare 'this' object to.
      Returns:
      true if contents of both objects are the same.
    • toFormattedString

      public final String toFormattedString(boolean isBer) throws com.oss.util.BadTimeValueException
      Converts the instance of ISO8601TimeInterface to the formatted string, suitable for the encoding. The string returned has the following format:
              YYYYMMDD
          or
              YYYY-MM-DD
          
      where YYYY is a four-digit year, and MM and DD mean month, day, hour, minute and second correspondingly. First form used to represent BER format. Second form means that the time is a value notation.
      Specified by:
      toFormattedString in class AbstractISO8601Time
      Parameters:
      isBer - set to true if the time value is to be BER format
      Returns:
      string that contain the value, formatted accordingly to the ISO8601Date format
      Throws:
      com.oss.util.BadTimeValueException - if the the value contains invalid components that make the formatting impossible
    • parseTime

      public ISO8601TimeInterface parseTime(String str, boolean isBer) throws BadTimeFormatException
      Takes formatted string that contains the value of ISO8601Date, splits the string to the components and initializes this instance of the ISO8601Date class. If the string has invalid format, a BadTimeFormatException exception is thrown. The method expects that the string has the format, specified in the description of the toFormattedString method.
      Specified by:
      parseTime in class AbstractISO8601Time
      Parameters:
      str - formatted string that contains the value of ISO8601Date
      isBer - set to true if the time value is to be BER format
      Returns:
      reference to this object
      Throws:
      BadTimeFormatException - if str has invalid format
    • hashCode

      public int hashCode()
      Returns a hash code for this object
      Overrides:
      hashCode in class AbstractData
      Returns:
      a hash code for this object
    • getTypeName

      public String getTypeName()
      Returns the name of ASN.1 type this java class represents.
      Overrides:
      getTypeName in class AbstractData
      Returns:
      the name of the ASN.1 type.