By length of number, I take it you mean the number of digits in the number.

Suppose you want only 3 digit numbers. The lowest would be 100 and highest would be 999
In pseudo code
1) Generate nextInt(1000)
2) Check if num >99. If yes, accept it, else reject it
3) Repeat