OptionalValidity (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.crmf

## Class OptionalValidity

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.crmf.OptionalValidity

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class OptionalValidity
      extends ASN1Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OptionalValidity(Time notBefore, Time notAfter)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static OptionalValidity` | `getInstance(ASN1TaggedObject taggedObject, boolean declaredExplicit)`
    `static OptionalValidity` | `getInstance(java.lang.Object o)`
    `Time` | `getNotAfter()`
    `Time` | `getNotBefore()`
    `static OptionalValidity` | `getTagged(ASN1TaggedObject taggedObject, boolean declaredExplicit)`
    `ASN1Primitive` | `toASN1Primitive()` OptionalValidity ::= SEQUENCE { notBefore [0] Time OPTIONAL, notAfter [1] Time OPTIONAL } --at least one MUST be present Time ::= CHOICE { ... }

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

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

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OptionalValidity

          public OptionalValidity(Time notBefore,
                                  Time notAfter)

  - ### Method Detail

    - #### getInstance

          public static OptionalValidity getInstance(java.lang.Object o)

    - #### getInstance

          public static OptionalValidity getInstance(ASN1TaggedObject taggedObject,
                                                     boolean declaredExplicit)

    - #### getTagged

          public static OptionalValidity getTagged(ASN1TaggedObject taggedObject,
                                                   boolean declaredExplicit)

    - #### getNotBefore

          public Time getNotBefore()

    - #### getNotAfter

          public Time getNotAfter()

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

           OptionalValidity ::= SEQUENCE {
               notBefore    [0] Time OPTIONAL,
               notAfter     [1] Time OPTIONAL } --at least one MUST be present

           Time ::= CHOICE { ... }

      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a basic ASN.1 object representation.