code: public void encode(OutputStream out) throws IOException {
  
          // in cases where default constructor is used check for
          // null values
          if (notBefore == null || notAfter == null) {
              throw new IOException("CertAttrSet:CertificateValidity:" +
                                    " null values to encode.\n");
          }
          DerOutputStream pair = new DerOutputStream();
  
          if (notBefore.getTime() < YR_2050) {
              pair.putUTCTime(notBefore);
          } else
              pair.putGeneralizedTime(notBefore);
  
          if (notAfter.getTime() < YR_2050) {
              pair.putUTCTime(notAfter);
          } else {
              pair.putGeneralizedTime(notAfter);
          }
          DerOutputStream seq = new DerOutputStream();
          seq.write(DerValue.tag_Sequence, pair);
  
          out.write(seq.toByteArray());
      }
docs: Encode the CertificateValidity period in DER form to the stream.
  
  @param out the OutputStream to marshal the contents to.
  @exception IOException on errors.