code: public String form( int x ) {
          String r;
          int s = 0;
  
          if (fmt == 'd' || fmt == 'i') {
              if (x < 0) {
                  r = ("" + x).substring(1);
                  s = -1;
              } else {
                  r = "" + x;
                  s = 1;
              }
          } else {
              long xl = x & 0x00000000FFFFFFFFL;
              if (fmt == 'u') {
                  r = "" + xl;
                  s = 1;
              } else if (fmt == 'o') {
                  r = convert(xl, 3, "01234567");
              } else if (fmt == 'x') {
                  r = convert(xl, 4, "0123456789abcdef");
              } else if (fmt == 'X') {
                  r = convert(xl, 4, "0123456789ABCDEF");
              } else {
                  throw new java.lang.IllegalArgumentException();
              }
          }
  
          return pad(sign(s, r));
      }
docs: Formats an integer into a string (like sprintf in C)
  
  @param x      the number to format
  
  @return the formatted string