List of usage examples for java.util.concurrent ThreadLocalRandom nextLong
public long nextLong(long origin, long bound)
From source file:com.toptal.conf.SampleDataConfiguration.java
/** * Adds entries to the given user./*from w w w. ja va 2 s .c o m*/ * @param user User. */ @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") private void addEntries(final User user) { final ThreadLocalRandom rnd = ThreadLocalRandom.current(); final int size = rnd.nextInt(10, 100); final Calendar cal = Calendar.getInstance(); final long end = cal.getTimeInMillis(); cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 2); final long start = cal.getTimeInMillis(); for (int idx = 0; idx < size; ++idx) { this.entries.save(Entry.builder().date(new Date(rnd.nextLong(start, end))) // @checkstyle MagicNumberCheck (2 lines) .distance(rnd.nextLong(500, 10000)).time(rnd.nextLong(120000, 2400000)).user(user).build()); } }