@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ASN1GeneralizedTime extends ASN1Element
getDate()
and getTime()
methods, although the original
string representation will be retained and will be used in the encoded
representation.Constructor and Description |
---|
ASN1GeneralizedTime()
Creates a new generalized time element with the default BER type that
represents the current time.
|
ASN1GeneralizedTime(byte type)
Creates a new generalized time element with the specified BER type that
represents the current time.
|
ASN1GeneralizedTime(byte type,
java.util.Date date)
Creates a new generalized time element with the specified BER type that
represents the indicated time.
|
ASN1GeneralizedTime(byte type,
long time)
Creates a new generalized time element with the specified BER type that
represents the indicated time.
|
ASN1GeneralizedTime(byte type,
java.lang.String timestamp)
Creates a new generalized time element with the specified BER type and a
time decoded from the provided string representation.
|
ASN1GeneralizedTime(java.util.Date date)
Creates a new generalized time element with the default BER type that
represents the indicated time.
|
ASN1GeneralizedTime(long time)
Creates a new generalized time element with the default BER type that
represents the indicated time.
|
ASN1GeneralizedTime(java.lang.String timestamp)
Creates a new generalized time element with the default BER type and a
time decoded from the provided string representation.
|
Modifier and Type | Method and Description |
---|---|
static ASN1GeneralizedTime |
decodeAsGeneralizedTime(ASN1Element element)
Decodes the provided ASN.1 element as a generalized time element.
|
static ASN1GeneralizedTime |
decodeAsGeneralizedTime(byte[] elementBytes)
Decodes the contents of the provided byte array as a generalized time
element.
|
static long |
decodeTimestamp(java.lang.String timestamp)
Decodes the provided string as a timestamp in the generalized time format.
|
static java.lang.String |
encodeTimestamp(java.util.Date date,
boolean includeMilliseconds)
Encodes the time represented by the provided date into the appropriate
ASN.1 generalized time format.
|
static java.lang.String |
encodeTimestamp(long time,
boolean includeMilliseconds)
Encodes the specified time into the appropriate ASN.1 generalized time
format.
|
java.util.Date |
getDate()
Retrieves a
Date object that is set to the time represented by this
generalized time element. |
java.lang.String |
getStringRepresentation()
Retrieves the string representation of the generalized time value contained
in this element.
|
long |
getTime()
Retrieves the time represented by this generalized time element, expressed
as the number of milliseconds since the epoch (the same format used by
System.currentTimeMillis() and Date.getTime() ). |
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of the value for this ASN.1 element to the
provided buffer.
|
decode, decodeAsBigInteger, decodeAsBitString, decodeAsBoolean, decodeAsEnumerated, decodeAsGeneralizedTime, decodeAsIA5String, decodeAsInteger, decodeAsLong, decodeAsNull, decodeAsNumericString, decodeAsObjectIdentifier, decodeAsOctetString, decodeAsPrintableString, decodeAsSequence, decodeAsSet, decodeAsUTCTime, decodeAsUTF8String, encode, encodeLength, encodeTo, equals, equalsIgnoreType, getType, getTypeClass, getValue, getValueLength, hashCode, isConstructed, readFrom, readFrom, toString, writeTo
public ASN1GeneralizedTime()
public ASN1GeneralizedTime(byte type)
type
- The BER type to use for this element.public ASN1GeneralizedTime(@NotNull java.util.Date date)
date
- The date value that specifies the time to represent. This
must not be null
.public ASN1GeneralizedTime(byte type, @NotNull java.util.Date date)
type
- The BER type to use for this element.date
- The date value that specifies the time to represent. This
must not be null
.public ASN1GeneralizedTime(long time)
time
- The time to represent. This must be expressed in
milliseconds since the epoch (the same format used by
System.currentTimeMillis()
and
Date.getTime()
).public ASN1GeneralizedTime(byte type, long time)
type
- The BER type to use for this element.time
- The time to represent. This must be expressed in
milliseconds since the epoch (the same format used by
System.currentTimeMillis()
and
Date.getTime()
).public ASN1GeneralizedTime(@NotNull java.lang.String timestamp) throws ASN1Exception
timestamp
- The string representation of the timestamp to represent.
This must not be null
.ASN1Exception
- If the provided timestamp does not represent a
valid ASN.1 generalized time string representation.public ASN1GeneralizedTime(byte type, @NotNull java.lang.String timestamp) throws ASN1Exception
type
- The BER type to use for this element.timestamp
- The string representation of the timestamp to represent.
This must not be null
.ASN1Exception
- If the provided timestamp does not represent a
valid ASN.1 generalized time string representation.@NotNull public static java.lang.String encodeTimestamp(@NotNull java.util.Date date, boolean includeMilliseconds)
date
- The date value that specifies the time to
represent. This must not be null
.includeMilliseconds
- Indicate whether the timestamp should include
a sub-second component representing a
precision of up to milliseconds. Note that
even if this is true
, the sub-second
component will only be included if it is not
all zeroes. If this is false
, then
the resulting timestamp will only use a
precision indicated in seconds, and the
sub-second portion will be truncated rather
than rounded to the nearest second (which is
the behavior that SimpleDateFormat
exhibits for formatting timestamps without a
sub-second component).@NotNull public static java.lang.String encodeTimestamp(long time, boolean includeMilliseconds)
time
- The time to represent. This must be expressed
in milliseconds since the epoch (the same
format used by
System.currentTimeMillis()
and
Date.getTime()
).includeMilliseconds
- Indicate whether the timestamp should include
a sub-second component representing a
precision of up to milliseconds. Note that
even if this is true
, the sub-second
component will only be included if it is not
all zeroes.public static long decodeTimestamp(@NotNull java.lang.String timestamp) throws ASN1Exception
timestamp
- The string representation of a generalized time to be
parsed as a timestamp. It must not be null
.System.currentTimeMillis()
and
Date.getTime()
).ASN1Exception
- If the provided timestamp cannot be parsed as a
valid string representation of an ASN.1 generalized
time value.public long getTime()
System.currentTimeMillis()
and Date.getTime()
).@NotNull public java.util.Date getDate()
Date
object that is set to the time represented by this
generalized time element.Date
object that is set ot the time represented by this
generalized time element.@NotNull public java.lang.String getStringRepresentation()
@NotNull public static ASN1GeneralizedTime decodeAsGeneralizedTime(@NotNull byte[] elementBytes) throws ASN1Exception
elementBytes
- The byte array to decode as an ASN.1 generalized time
element.ASN1Exception
- If the provided array cannot be decoded as a
generalized time element.@NotNull public static ASN1GeneralizedTime decodeAsGeneralizedTime(@NotNull ASN1Element element) throws ASN1Exception
element
- The ASN.1 element to be decoded.ASN1Exception
- If the provided element cannot be decoded as a
generalized time element.public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in class ASN1Element
buffer
- The buffer to which to append the information.