Here you can find the source of getRandomDate()
public static Date getRandomDate()
//package com.java2s; /**/* w w w . j av a 2 s .co m*/ * Logspace * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved. * This program and the accompanying materials are made available under the terms of * the Eclipse Public License Version 1.0, which accompanies this distribution and * is available at http://www.eclipse.org/legal/epl-v10.html. */ import static java.util.concurrent.TimeUnit.DAYS; import java.util.Date; import java.util.Random; public class Main { private static final Random RANDOM = new Random(); public static Date getRandomDate() { long time = (long) (System.currentTimeMillis() - getRandomDouble() * DAYS.toMillis(3650)); // set the milliseconds to 0 time = time / 1000 * 1000; return new Date(time); } public static double getRandomDouble() { return RANDOM.nextDouble(); } }