Question: > 
> **Possible Duplicate:**  
> 
> [Java random number with given length](https://stackoverflow.com/questions/5392693/java-random-number-with-given-length) 
> 
> 
> 

I have been trying to generate a 15 digit long number in java but it seems I have failed to do it so far as using:

This is producing a maximum of 10 digits. 

```
  Random random = new Random();
  int rand15Digt = random.nextInt(15);

```

How can I generate it successfully?

Answer: 
What about trying `BigInteger`, see this StackOverflow link for more information [Random BigInteger Generation](https://stackoverflow.com/questions/2290057/how-to-generate-a-random-biginteger-value-in-java)
In Hibernate have `UUIDGenerator` class using this we can create Secure Random and Unique Number also.

```
public Serializable generate(SessionImplementor session, Object object)
        throws HibernateException {
    String uuid = (String)super.generate(session, object);
    return uuid.substring(uuid.length()-15, uuid.length());
}

```

i think this is best way to Generate Unique and also Random Number...