I would like to ask what is the most suitable way to create List of Dates for specific year to hold the dates of this year.
I have written the following and it works fine. However,I am not sure that this the most convenient way.
Calendar cal = new GregorianCalendar(2012, Calendar.JANUARY, 1);
Date startDate = cal.getTime();
cal = new GregorianCalendar(2013, Calendar.JANUARY, 1);
Date endDate = cal.getTime();
List<Date> dates = new ArrayList<Date>();
Calendar calendar = new GregorianCalendar();
calendar.setTime(startDate);
while (calendar.getTime().before(endDate)) {
Date date= calendar.getTime();
dates.add(date);
calendar.add(Calendar.DATE, 1);
}