Package com.oss.asn1

Class UTCTime

All Implemented Interfaces:
Serializable, Cloneable

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

    • UTCTime

      public UTCTime()
      The default constructor.
    • UTCTime

      public UTCTime(int year, int month, int day, int hour, int minute, int second, int minDiff)
      Construct from individual time components.
    • UTCTime

      public UTCTime(int[] components)
      Construct an instance of this class from an int array. The int array contains the time components in the order: year, month, day, hour, minute, second, minute-differential.
      Parameters:
      components - an int array of time components.
    • UTCTime

      public UTCTime(String value) throws BadTimeFormatException
      Construct an instance of this class from a String containing value notation of the UTCTime.
      Parameters:
      value - string containing GeneralizedTime value.
      Throws:
      BadTimeFormatException - if value has invalid format
      See Also:
  • Method Details

    • clone

      public UTCTime clone()
      Clone 'this' object.
      Overrides:
      clone in class AbstractTime
      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 UTCTime. The value notation has the following format:
                 YYMMDDHHMMSS+hhmm
             or
                 YYMMDDHHMMSS-hhmm
             or
                 YYMMDDHHMMSSZ
             
             where YY is a two-digit year, and MM,
             DD, HH, MM and SS
             mean month, day, hour, minute and second. The string ends either with
             Z, which means that the value is UTC time, or with time
             differential. hh mean hour difference and mm
             means minute differential.
      Parameters:
      value - string containing UTCTime value.
      Throws:
      BadTimeFormatException - if value has invalid format
    • equalTo

      public final boolean equalTo(UTCTime that)
      Compare 'this' object to another UTCTime object to see if their contents are the same.
      Parameters:
      that - the UTCTime object to compare 'this' object to.
      Returns:
      true if contents of both objects are the same. comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • compareTo

      public final int compareTo(UTCTime that)
      Compare 'this' object to another UTCTime object to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.
      Parameters:
      that - the UTCTime object to compare 'this' object to.
      Returns:
      LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • compareTo

      public final int compareTo(UTCTime that, TimeZone zone, Locale locale)
      Compare 'this' object to another object of the same class to determine whether the contents of this object is less than, equal to, or greater than the contents of other object.
      Parameters:
      that - the UTCTime object to compare 'this' object to.
      zone - the TimeZone object to use during comparison.
      locale - the Locale object to use during comparison.
      Returns:
      LESS_THAN, EQUALS, GREATER_THAN values as the results of comparison.
      Throws:
      NullPointerException - thrown when 'that' is null.
    • formatTime

      public final String formatTime() throws com.oss.util.BadTimeValueException
      Takes the instance of AbstractTime and converts it to the formatted string, suitable for the encoding. The string returned has the following format:
              YYMMDDHHMMSS+hhmm
          or
              YYMMDDHHMMSS-hhmm
          or
              YYMMDDHHMMSSZ
          
          where YY is a two-digit year, and MM,
          DD, HH, MM and SS
          mean month, day, hour, minute and second. The string ends either with
          Z, which means that the value is UTC time, or with time
          differential. hh mean hour difference and mm
          means minute differential.
      Specified by:
      formatTime in class AbstractTime
      Returns:
      string that contain the value, formatted accordingly to the UTCTime format
      Throws:
      com.oss.util.BadTimeValueException - if the the value contains invalid components that make the formatting impossible
    • parseTime

      public AbstractTime parseTime(String str) throws BadTimeFormatException
      Takes formatted string that contains the value of UTCTime, splits the string to the components and initializes the instance of the AbstractTime 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 formatTime method.
      Specified by:
      parseTime in class AbstractTime
      Parameters:
      str - formatted string that contains the value of UTCTime
      Returns:
      reference to initialized object
      Throws:
      BadTimeFormatException - if str has invalid format
    • 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.