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

    Constructors
    Constructor
    Description
    BinaryTime(long seconds)
    Construct a BinaryTime carrying the supplied count of seconds since 1970-01-01T00:00:00Z (UTC).
    Construct a BinaryTime carrying the seconds-since-epoch of the supplied Date.
    BinaryTime(org.bouncycastle.asn1.ASN1Integer time)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static BinaryTime
     
    org.bouncycastle.asn1.ASN1Integer
     
    org.bouncycastle.asn1.ASN1Primitive
     
    Convert the encoded value to a Date.

    Methods inherited from class org.bouncycastle.asn1.ASN1Object

    encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BinaryTime

      public BinaryTime(Date date)
      Construct a BinaryTime carrying the seconds-since-epoch of the supplied Date. Sub-second components are discarded by truncation toward negative infinity (consistent with Date.getTime() / 1000).
      Throws:
      IllegalArgumentException - if date is 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 - if seconds is negative.
    • BinaryTime

      public BinaryTime(org.bouncycastle.asn1.ASN1Integer time)
  • Method Details

    • getInstance

      public static BinaryTime getInstance(Object obj)
    • getTime

      public org.bouncycastle.asn1.ASN1Integer getTime()
      Returns:
      the encoded value as a count of seconds since the Unix epoch. May exceed Long.MAX_VALUE on a wildly out-of-range encoding; callers that only need a Date may prefer toDate() which rejects unrepresentable values.
    • toDate

      public Date toDate()
      Convert the encoded value to a Date.
      Throws:
      ArithmeticException - if the seconds value does not fit in a long after multiplication by 1000.
    • toASN1Primitive

      public org.bouncycastle.asn1.ASN1Primitive toASN1Primitive()
      Specified by:
      toASN1Primitive in interface org.bouncycastle.asn1.ASN1Encodable
      Specified by:
      toASN1Primitive in class org.bouncycastle.asn1.ASN1Object