title: Java store every date of a year in array
body: <p>I want to create ArrayLists of every year and I want each date in that year saved in the corresponding ArrayList. How would I be able to do that? It is possible with Calendar?</p>
  
  <p>EDIT:</p>
  
  <p>So now I have this, anyone knows why it only prints 2013/12/31 and not all the dates of that year?</p>
  
  <pre><code>Calendar cal = Calendar.getInstance();
  int current = cal.get(Calendar.YEAR);
  ArrayList&lt;String&gt; current_year = getDatesOfYear(current);
  </code></pre>
  
  <p>The method:</p>
  
  <pre><code>private ArrayList&lt;String&gt; getDatesOfYear(int year){
      ArrayList&lt;String&gt; dates = new ArrayList&lt;String&gt;();
      Calendar cal = Calendar.getInstance();
      cal.set(year+1,0,0);
      while(cal.get(Calendar.YEAR)==year){
          DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
          String date = df.format(cal.getTime());
          dates.add(date);
          System.out.println(date);
          cal.add(Calendar.DATE, 1);
      }
      return dates;
  }
  </code></pre>