code: public void appendDigits(long num, int mindigits, int maxdigits,  
                             StringBuffer sb) {
      char[] buf = new char[maxdigits];
      int ix = maxdigits;
      while (ix > 0 && num > 0) {
        buf[--ix] = (char)(dr.zero + (num % 10));
        num /= 10;
      }
      for (int e = maxdigits - mindigits; ix > e;) {
        buf[--ix] = dr.zero;
      }
      sb.append(buf, ix, maxdigits - ix);
    }
docs: Append digits to the string builder, using this.zero for '0' etc.
  
  @param num the integer to append
  @param mindigits the minimum number of digits to append
  @param maxdigits the maximum number of digits to append
  @param sb the string builder to which to append the text