Class BinaryTime
java.lang.Object
org.bouncycastle.asn1.ASN1Object
org.bouncycastle.asn1.cms.BinaryTime
- All Implemented Interfaces:
org.bouncycastle.asn1.ASN1Encodable, org.bouncycastle.util.Encodable
public class BinaryTime
extends org.bouncycastle.asn1.ASN1Object
RFC 6019
BinaryTime
type — the unsigned integer count of seconds since 1970-01-01T00:00:00Z (UTC).
BinaryTime ::= INTEGER (0..MAX)Used by other LAMPS specifications that need a compact, monotonically increasing time value as part of an ASN.1 structure (e.g. RFC 9763
RequesterCertificate.requestTime).
The companion id-aa-binarySigningTime CMS signed attribute OID is
available as
PKCSObjectIdentifiers.pkcs_9_at_binarySigningTime.-
Constructor Summary
ConstructorsConstructorDescriptionBinaryTime(long seconds) Construct a BinaryTime carrying the supplied count of seconds since 1970-01-01T00:00:00Z (UTC).BinaryTime(Date date) Construct a BinaryTime carrying the seconds-since-epoch of the suppliedDate.BinaryTime(org.bouncycastle.asn1.ASN1Integer time) -
Method Summary
Modifier and TypeMethodDescriptionstatic BinaryTimegetInstance(Object obj) org.bouncycastle.asn1.ASN1IntegergetTime()org.bouncycastle.asn1.ASN1PrimitivetoDate()Convert the encoded value to aDate.Methods inherited from class org.bouncycastle.asn1.ASN1Object
encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode
-
Constructor Details
-
BinaryTime
Construct a BinaryTime carrying the seconds-since-epoch of the suppliedDate. Sub-second components are discarded by truncation toward negative infinity (consistent withDate.getTime()/ 1000).- Throws:
IllegalArgumentException- ifdateis before the epoch (RFC 6019 prohibits negative values).
-
BinaryTime
public BinaryTime(long seconds) Construct a BinaryTime carrying the supplied count of seconds since 1970-01-01T00:00:00Z (UTC).- Throws:
IllegalArgumentException- ifsecondsis negative.
-
BinaryTime
public BinaryTime(org.bouncycastle.asn1.ASN1Integer time)
-
-
Method Details
-
getInstance
-
getTime
public org.bouncycastle.asn1.ASN1Integer getTime()- Returns:
- the encoded value as a count of seconds since the Unix epoch.
May exceed
Long.MAX_VALUEon a wildly out-of-range encoding; callers that only need a Date may prefertoDate()which rejects unrepresentable values.
-
toDate
Convert the encoded value to aDate.- Throws:
ArithmeticException- if the seconds value does not fit in alongafter multiplication by 1000.
-
toASN1Primitive
public org.bouncycastle.asn1.ASN1Primitive toASN1Primitive()- Specified by:
toASN1Primitivein interfaceorg.bouncycastle.asn1.ASN1Encodable- Specified by:
toASN1Primitivein classorg.bouncycastle.asn1.ASN1Object
-