Here you can find the source of getRandomLocalDateBetween(int startYear, int endYear)
public static LocalDate getRandomLocalDateBetween(int startYear, int endYear)
//package com.java2s; //License from project: Open Source License import java.time.LocalDate; import java.util.Random; public class Main { public static LocalDate getRandomLocalDateBetween(int startYear, int endYear) { Random random = new Random(); int min = (int) LocalDate.of(startYear, 1, 1).toEpochDay(); int max = (int) LocalDate.of(endYear, 1, 1).toEpochDay(); long randomDay = min + random.nextInt(max - min); return LocalDate.ofEpochDay(randomDay); }/*from w ww . ja va 2s. c o m*/ }