code: public long getTimeLeft() {
          Date earliestTime = null;
          for (int i = 0; i < this.certChain.length; i++) {
              Date time = this.certChain[i].getNotAfter();
              if (earliestTime == null || time.before(earliestTime)) {
                  earliestTime = time;
              }
          }
          long diff = (earliestTime.getTime() - System.currentTimeMillis()) / 1000;
          return (diff < 0) ? 0 : diff;
      }
docs: Returns time left of this credential. The time left of the credential is based on the certificate with
  the shortest validity time.
  
  @return time left in seconds. Returns 0 if the certificate has expired.