Convenient way to generate dates of year
<p>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.</p>

<p>I have written the following and it works fine.
However,I am not sure that this the most convenient way.</p>

<pre><code>        Calendar cal = new GregorianCalendar(2012, Calendar.JANUARY, 1);
        Date startDate = cal.getTime();

        cal = new GregorianCalendar(2013, Calendar.JANUARY, 1);
        Date endDate = cal.getTime();


        List&lt;Date&gt; dates = new ArrayList&lt;Date&gt;();
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(startDate);

        while (calendar.getTime().before(endDate)) {
            Date date= calendar.getTime();
            dates.add(date);
            calendar.add(Calendar.DATE, 1);
        }
</code></pre>
