I want to implement a Java method to test data:
public List<DashboardDTO> testDate() {
String sourceDate = "2012-02-29";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date myDate;
List<DashboardDTO> list = new ArrayList<>();
try {
myDate = format.parse(sourceDate);
for (int i = 0; i <= 10; i++) {
DashboardDTO obj = new DashboardDTO();
obj.setAmount(400);
obj.setDate(myDate);
obj.setNumber_of_transactions(33);
list.add(obj);
}
} catch (ParseException e) {
e.printStackTrace();
}
return list;
}
How I can generate test Date in the loop? I want to specify a range of random Dates.