package danielcortes.xyz.utils;

import java.time.LocalDate;
import java.util.concurrent.ThreadLocalRandom;

public class RandomLocalDate {
  private static final LocalDate DEFAULT_FROM = LocalDate.of(1970,1,1);
  private static final LocalDate DEFAULT_TO = LocalDate.of(2038,1,19);

  public static LocalDate random(){
    return randomBetween(DEFAULT_FROM, DEFAULT_TO);
  }

  public static LocalDate randomBetween(LocalDate from, LocalDate to){
    long min = from.toEpochDay();
    long max = to.toEpochDay();
    long random = ThreadLocalRandom.current().nextLong(min, max);
    return LocalDate.ofEpochDay(random);
  }

}
