Code example for CertificateNotYetValidException

0
            notBefore = tbsCert.getValidity().getNotBefore().getTime();
            notAfter = tbsCert.getValidity().getNotAfter().getTime();
        } 
        long time = System.currentTimeMillis();
        if (time < notBefore) {
            throw new CertificateNotYetValidException();
        } 
        if (time > notAfter) {
            throw new CertificateExpiredException();
        } 
    } 
 
    /** 
     * @see java.security.cert.X509Certificate#checkValidity(Date) 
     * method documentation for more information. 
     */ 
    public void checkValidity(Date date)
                                throws CertificateExpiredException, 
                                       CertificateNotYetValidException { 
        if (notBefore == -1) {
            // retrieve and cache the value of validity period