Package com.oss.asn1
Class UTCTime
java.lang.Object
com.oss.asn1.AbstractData
com.oss.asn1.AbstractTime
com.oss.asn1.UTCTime
- All Implemented Interfaces:
Serializable
,Cloneable
The UTCTime class represents the ASN.1 UTCTime type
- Since:
- ASN.1/Java 6.0
- See Also:
-
Field Summary
Fields inherited from class com.oss.asn1.AbstractData
EQUALS, GREATER_THAN, LESS_THAN
-
Constructor Summary
ConstructorsConstructorDescriptionUTCTime()
The default constructor.UTCTime
(int[] components) Construct an instance of this class from an int array.UTCTime
(int year, int month, int day, int hour, int minute, int second, int minDiff) Construct from individual time components.Construct an instance of this class from a String containing value notation of the UTCTime. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone 'this' object.final int
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.final int
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.final boolean
Compare 'this' object to another UTCTime object to see if their contents are the same.final String
Takes the instance ofAbstractTime
and converts it to the formatted string, suitable for the encoding.Returns the name of ASN.1 type this java class represents.Takes formatted string that contains the value of UTCTime, splits the string to the components and initializes the instance of theAbstractTime
class, passed as a parameter.void
Set an instance of this class from a String containing value notation of the UTCTime.Methods inherited from class com.oss.asn1.AbstractTime
getDay, getHour, getMinute, getMinuteDifferential, getMonth, getSecond, getYear, hashCode, intArrayValue, setDay, setHour, setMinute, setMinuteDifferential, setMonth, setSecond, setValue, setYear, toDate, toDate, validateTime
Methods inherited from class com.oss.asn1.AbstractData
delete, equals, isEncodable, isPDU, isValid, toString, toString
-
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
Construct an instance of this class from a String containing value notation of the UTCTime.- Parameters:
value
- string containing GeneralizedTime value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format- See Also:
-
-
Method Details
-
clone
Clone 'this' object.- Overrides:
clone
in classAbstractTime
- Returns:
- deep copy of 'this' object.
-
setValue
Set an instance of this class from a String containing value notation of the UTCTime. The value notation has the following format:YYMMDDHHMMSS+hhmm
orYYMMDDHHMMSS-hhmm
orYYMMDDHHMMSSZ
where
YY
is a two-digit year, andMM
,DD
,HH
,MM
andSS
mean month, day, hour, minute and second. The string ends either withZ
, which means that the value is UTC time, or with time differential.hh
mean hour difference andmm
means minute differential.- Parameters:
value
- string containing UTCTime value.- Throws:
BadTimeFormatException
- ifvalue
has invalid format
-
equalTo
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
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
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
Takes the instance ofAbstractTime
and converts it to the formatted string, suitable for the encoding. The string returned has the following format:YYMMDDHHMMSS+hhmm
orYYMMDDHHMMSS-hhmm
orYYMMDDHHMMSSZ
where
YY
is a two-digit year, andMM
,DD
,HH
,MM
andSS
mean month, day, hour, minute and second. The string ends either withZ
, which means that the value is UTC time, or with time differential.hh
mean hour difference andmm
means minute differential.- Specified by:
formatTime
in classAbstractTime
- 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
Takes formatted string that contains the value of UTCTime, splits the string to the components and initializes the instance of theAbstractTime
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 theformatTime
method.- Specified by:
parseTime
in classAbstractTime
- Parameters:
str
- formatted string that contains the value of UTCTime- Returns:
- reference to initialized object
- Throws:
BadTimeFormatException
- ifstr
has invalid format
-
getTypeName
Returns the name of ASN.1 type this java class represents.- Overrides:
getTypeName
in classAbstractData
- Returns:
- the name of the ASN.1 type.
-