Returns a string containing a set of numbers with a fixed number of digits

@param digits number of digits in the final number
@return Random number as a string with a fixed length
322039
public String getNumberText(final int digits) {
    String result = "";
    for (int i = 0; i < digits; i++) {
      result = result + random.nextInt(10);
    }
    return result;
  }
1058702
def gen_random_string(str_len):
    
    return ''.join(
        random.choice(string.ascii_letters + string.digits) for _ in range(str_len))
949620
def random_string(**kwargs):
    
    n = kwargs.get('length', 10)
    pool = kwargs.get('pool') or string.digits + string.ascii_lowercase
    return ''.join(random.SystemRandom().choice(pool) for _ in range(n))
345905
public static NumberFormat makeNumberFormat(int digits) {
    // Prefer predefined number formats where applicable.
    // TODO: cache others, too?
    switch(digits){
    case 0:
      return NF0;
    case 2:
      return NF2;
    case 3:
      return NF3;
    case 4:
      return NF4;
    case 6:
      return NF6;
    case 8:
      return NF8;
    }
    final NumberFormat nf = NumberFormat.getInstance(Locale.US);
    nf.setMaximumFractionDigits(digits);
    nf.setMinimumFractionDigits(digits);
    nf.setGroupingUsed(false);
    return nf;
  }
840159
public String getIntegerPartAfter(final int digit) {
        
        final int length = integerPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        String num = integerPart.substring(0, (length - digit + 1));
        if(isUseSeparator() && digit >= 4) {
            // 区切り文字を入れるために分割する。
            StringBuilder sb = new StringBuilder();
            for(int i=0; i < num.length(); i++) {
                char c = num.charAt(i);
                sb.append(c);
                
                // 現在の処理中の桁数
                int itemDigit = length -i;
                if((itemDigit >= 3) && (itemDigit -1) % 3 == 0) {
                    sb.append(",");
                }
            }
            
            num = sb.toString();
        }
        
        return num;
        
    }
74866
public String getExponentPartAfter(final int digit) {
        
        final int length = exponentPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        return exponentPart.substring(0, length - digit + 1);
        
    }
1096163
public static String randomString(int length) {
        Preconditions.checkArgument(length > MIN_PASSWORD_LENGTH, "random string length must be at least 1 character");
        Preconditions.checkArgument(length <= MAX_PASSWORD_LENGTH, "random string length must be at most 256 character");
        
        return RandomStringUtils.random(length, 0, CHARACTERS.length-1, false, false, CHARACTERS, new SecureRandom());
    }
201009
public static String generateRandomId() {

        StringBuffer buffer = new StringBuffer();
        int base = 36;
        for (int i = 0; i < 16; i++) {
            buffer.append(Integer.toString(RANDOM.nextInt(base), base));
        }
        return buffer.toString();
    }
735002
function(digits, n) {
		n = n.toString();
		while(n.length < digits)
		n = '0' + n;
		return n;
	}
753562
private String digits() {
    StringBuilder sb = new StringBuilder();
    do {
      sb.append(consumeNextCharacter(CharType.DIGIT));
    } while (chars.positiveLookahead(CharType.DIGIT));
    return sb.toString();
  }
300622
public static String bitString(long number) {
        return String.format(Locale.ROOT,"%064d", new BigInteger(Long.toBinaryString(number)));
    }
503582
public static String generate(Integer length) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(seed.length());
            sb.append(seed.charAt(number));
        }
        return sb.toString();
    }
127239
function (number, digits) {
    if (typeof number !== "number") { throw "not a number: " + number; }
    var s = number.toString();
    if (number.length > digits) {
      return number.substr(number.length - digits, number.length);
    }
    while (s.length < digits) {
      s = '0' + s;
    }
    return s;
  }
1127736
public String getWholeNumberPart(final int digit) {
        
        final int length = wholeNumberPart.length();
        if(length < digit || digit <= 0) {
            return "";
        }
        
        return String.valueOf(wholeNumberPart.charAt(length - digit));
    }
1260359
def __generate_string(length):  # pragma: no cover
        """"""
        return ''.join(
            SystemRandom().choice(string.ascii_letters + string.digits)
            for x in range(length)).encode()
852877
static String zeroPrepend(long num, int digits) {
		String numStr = Long.toString(num);
		if (numStr.length() >= digits) {
			return numStr;
		} else {
			return String.format("%0" + digits + "d", num);
		}
	}
776856
public static String random(int len) {
        final char[] chars = {'0', '1', '2', '3', '4',
                '5', '6', '7', '8', '9', '$', '#', '^', '&', '_',
                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
                'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
                'u', 'v', 'w', 'x', 'y', 'z',
                'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
                'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
                'U', 'V', 'W', 'X', 'Y', 'Z',
                '~', '!', '@'};

        final int max = chars.length;
        Random r = new Random();
        StringBuilder sb = new StringBuilder(len);
        while(len-- > 0) {
            int i = r.nextInt(max);
            sb.append(chars[i]);
        }
        return sb.toString();
    }