Package com.oss.asn1

Class GeneralizedTime

All Implemented Interfaces:
Serializable, Cloneable

public class GeneralizedTime extends AbstractTime
The GeneralizedTime class represents the ASN.1 GeneralizedTime type.
Since:
ASN.1/Java 1.0-beta A
See Also:
  • Constructor Details

    • GeneralizedTime

      public GeneralizedTime()
      The default constructor.
    • GeneralizedTime

      public GeneralizedTime(int year, int month, int day, int hour, int minute, int second, int minDiff, int millisecond, boolean isUTCTime)
      Construct from individual time components.
      Parameters:
      year - the year to set.
      month - the month to set.
      day - the day to set.
      hour - the hour to set.
      minute - the minute to sey.
      second - the second to set.
      minDiff - the minute-differential to set.
      millisecond - the millisecond to set.
      isUTCTime - true if 'Z' is included.
    • GeneralizedTime

      public GeneralizedTime(int[] components, boolean isUTCTime)
      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 and millisecond.
      Parameters:
      components - the int array of time components.
      isUTCTime - true if 'Z' is included.
    • GeneralizedTime

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

    • getMillisecond

      public final int getMillisecond()
      Get the millisecond component of 'this' object.
      Returns:
      an int indicating the millisecond.
    • setMillisecond

      public final void setMillisecond(int millisecond)
      Set the millisecond component of 'this' object.
      Parameters:
      millisecond - the millisecond to set.
    • getIsUTCTime

      public final boolean getIsUTCTime()
      Determine whether this GeneralizedTime represents a UTCTime value (with 'Z').
      Returns:
      boolean indicating the status as UTCTime.
    • setIsUTCTime

      public final void setIsUTCTime(boolean isUTCTime)
      Specify that this GeneralizedTime should represent UTCTime.
      Parameters:
      isUTCTime - true if UTCTime, false if GeneralizedTime.
    • setMinuteDifferential

      public final void setMinuteDifferential(int minDiff)
      Set the minute-differential component of 'this' object if the isUTCTime flag is false. Otherwise, do nothing.
      Overrides:
      setMinuteDifferential in class AbstractTime
      Parameters:
      minDiff - the minute-differential to set.
    • intArrayValue

      public final int[] intArrayValue()
      Get an int array containing the components of 'this' object. The components are in the order: year, month, day, hour, minute, second, minute-differential, millisecond.
      Overrides:
      intArrayValue in class AbstractTime
      Returns:
      int array of time components.
    • setValue

      public final void setValue(int[] components, boolean isUTCTime)
      Set the value of a GeneralizedTime from an array of int that contains the year, month, day, hour, minute, second, minute-differential and millisecond.
      Parameters:
      components - an array of time components.
      isUTCTime - a boolean specified whether this GeneralizedTime represents UTCTime with 'Z'.
    • setValue

      public void setValue(String value) throws BadTimeFormatException
      Set an instance of this class from a String containing value notation of the GeneralizedTime. The value notation has the following format:
                 YYYYMMDDHHMMSS[.FFF]+hhmm
             or
                 YYYYMMDDHHMMSS[.FFF]-hhmm
             or
                 YYYYMMDDHHMMSS[.FFF]
             or
                 YYYYMMDDHHMMSS[.FFF]Z
             
      where YYYY is a four-digit year, and MM, DD, HH, MM, SS and FFF mean month, day, hour, minute, second and fractions of second (millisecond) correspondingly. If millisecond equal to zero, the fractional part (including the decimal point) is omitted. First two forms used to represent values with non-zero minute differential. Third form means that the time is a local time and the fourth form used to represent UTC time.
      Parameters:
      value - string containing GeneralizedTime value.
      Throws:
      BadTimeFormatException - if value has invalid format
    • toDate

      public final Date toDate(Calendar calendar)
      Get a Java Date object primed with the data from 'this' AbstractTime object using the calendar "calendar". Note that the precision is milliseconds.
      Overrides:
      toDate in class AbstractTime
      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".
    • equalTo

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

      public final int compareTo(GeneralizedTime that)
      Compare 'this' object to another GeneralizedTime 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 GeneralizedTime 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(GeneralizedTime 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 GeneralizedTime 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.