Package com.oss.asn1

Class AbstractISO8601Time

java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractISO8601Time
All Implemented Interfaces:
com.oss.asn1.Comparable, ISO8601TimeInterface, Serializable, Cloneable
Direct Known Subclasses:
ISO8601Date, ISO8601DateTime, ISO8601Duration, ISO8601TimeOfDay

public abstract class AbstractISO8601Time extends AbstractData implements ISO8601TimeInterface, com.oss.asn1.Comparable
The ISO8601Time class implements the functionality common to all ASN.1 useful time types: DATE, TIME-OF-DAY, DATE-TIME and DURATION.

This abstract base class is a public class, but it is not considered as being part of the public API and should not be directly referenced in your application programs.

Since:
ASN.1/Java 6.0
See Also:
  • Constructor Details

    • AbstractISO8601Time

      public AbstractISO8601Time()
      The default constructor.
  • Method Details

    • setValue

      public abstract void setValue(String value) throws BadTimeFormatException
      Set an instance of this class from a String containing value notation of the TIME.
      Parameters:
      value - a string containing time value.
      Throws:
      BadTimeFormatException - if value has invalid format
    • toDate

      public final Date toDate()
      Get a Java Date object primed with the data from 'this' AbstractISO8601Time object.
      Returns:
      reference to the Java Date object set to 'this' object's year, month, day, hour, minute and second.
    • toDate

      public Date toDate(Calendar calendar)
      Get a Java Date object primed with the data from 'this' AbstractISO8601Time object using the calendar "calendar".
      Parameters:
      calendar - the Calendar to use to compute the Date.
      Returns:
      reference to the Java Date set to 'this' object's year, month, day, hour, minute and second by using "calendar".
    • compareTo

      public int compareTo(AbstractISO8601Time that)
      Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object. The contents of Java Date objects primed with the data from 'this' object and another object are compared.
      Parameters:
      that - the AbstractISO8601Time object to compare this object to.
      Returns:
      LESS_THAN (-1) if the date specified by 'this' before the date specified by "that". EQUALS (0) if the date specified by 'this' is the same as the date specified by "that". GREATER_THAN (1) if the date specified by 'this' after the date specified by "that".
    • compareTo

      public int compareTo(AbstractISO8601Time that, TimeZone zone, Locale locale)
      Compare 'this' object to another AbstractISO8601Time object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object. The contents of Java Date objects primed with the data from 'this' object and another object are compared.
      Parameters:
      that - the AbstractISO8601Time object to compare this object to.
      zone - specifies the time zone.
      locale - specifies the locale.
      Returns:
      LESS_THAN (-1) if the date specified by 'this' before the date specified by "that". EQUALS (0) if the date specified by 'this' is the same as the date specified by "that". GREATER_THAN (1) if the date specified by 'this' after the date specified by "that".
    • toFormattedString

      public abstract String toFormattedString(boolean isBer) throws com.oss.util.BadTimeValueException
      Converts the instance of ISO8601TimeInterface to the formatted string, suitable for the encoding.
      Parameters:
      isBer - set to true if the time value is to be BER format
      Returns:
      string that contain the value, formatted accordingly to the ISO8601 format
      Throws:
      com.oss.util.BadTimeValueException - if the the value contains invalid components that make the formatting impossible
    • parseTime

      public abstract ISO8601TimeInterface parseTime(String str, boolean isBer) throws BadTimeFormatException
      Takes formatted string that contains the value of AbstractISO8601Time, splits the string to the components and initializes the instance of the AbstractISO8601Time class, passed as a parameter. 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.
      Parameters:
      str - formatted string that contains the value of UTCTime
      isBer - indicates that the value is in special format, required by BER.
      Returns:
      reference to initialized object
      Throws:
      BadTimeFormatException - if str has invalid format
    • validateTime

      public final boolean validateTime(int tag) throws com.oss.util.BadTimeValueException
      Does basic sanity checks for the value of useful time types. This version of the method checks if:
      1. the year is later than 1582
      2. the month is in range 1..12
      3. the day is in range 1..31
      4. the hour is in range 0..24
      5. the minute is in range 0..59
      6. the second is in range 0..60
      If this is not the case a BadTimeValueException exception is thrown.
      Parameters:
      tag - ASN.1 UNIVERSAL tag that identifies the subtype of TIME type.
      Returns:
      true if value passed validation check
      Throws:
      com.oss.util.BadTimeValueException - if any component has an illegal value.
    • clone

      public Object clone()
      Create a deep copy of 'this' object.
      Returns:
      copy of 'this' object.