public class GeneralizedTime extends ASN1Object
GeneralizedTime is a simple useful ASN.1 string type identified by the UNIVERSAL TAG number 24.
An ASN.1 GeneralizedTime object is used to represent time values with a
higher precision than done by the UTCTime ASN.1 type (allows a precision
down to seconds). A GeneralizedTime value specifies the calendar date
according to ISO 2014 (year, month, day: YYYYMMDD), the time value
(any precision) and optionally the local time-shift against Coordinated
Universal Time (UTC time).
Z terminating the time value indicates that it corresponds
to UTC time.
For instance: local time is GMT and represents the twelfth November 1997 at 15:30:10,5p.m:
GeneralizedTime genTime = new GeneralizedTime("19971112153010.5Z");
Supposing a time-shift of two hours making the local time ahead from GMT, we may write:
GeneralizedTime genTime = new GeneralizedTime("19971112173010.5+0200");When calling the
getValuemethod for getting the inherent value from an ASN.1 GeneralizedTime instance, a Java object of type
String timeStr = (String)genTime.getValue();DER en/decoding generally is done by means of the several methods of the
DerCoderclass; decoding alternatively may be performed by using the
|Modifier||Constructor and Description|
Creates an empty object.
Creates a new ASN.1 GeneralizedTime object for the given Java String value.
|Modifier and Type||Method and Description|
Decodes a GeneralizedTime value from the given InputStream.
DER encodes this GerneralizedTime ASN1Object and writes the result to given output stream.
Returns the value of this GeneralizedTime as a String.
Sets the value of this GeneralizedTime.
Returns a string that represents the contents of this GeneralizedTime.
addComponent, addEncodeListener, clone, countComponents, encodeObject, getAsnType, getComponentAt, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength
public GeneralizedTime(java.lang.String value)
value- the String value this GeneralizedTime object should represent
public java.lang.Object getValue()
public void setValue(java.lang.Object object)
protected void encode(java.io.OutputStream os) throws java.io.IOException
encodemethods of the
DerCoderclass for performing the encoding, and the DerCoder internally will call this
protected void decode(int length, java.io.InputStream is) throws java.io.IOException
lengthbytes to be read represent the value of an ASN.1 object of type GeneralizedTime.
This is a protected method and will not be used by
an application for decoding a DER encoded GeneralizedTime.
An application will call one of the
DerCoder class for performing
the decoding. The DerCoder then determines the number of
length) occupied by the value of this GeneralizedTime
object and internally calls this
method for actually reading the value.
length- the already decoded length, i.e. number of the bytes representing the value of the GeneralizedTime to be decoded
is- the input stream from which the DER encoded data is read in
java.io.IOException- if there is a problem with the InputStream