title: How to get the list of dates in a given date range?
body: <p>I am trying to get the list of dates between in a date range in iso format ("yyyy-MM-dd"), as follows:</p>
  
  <pre><code>ArrayList&lt;String&gt; datesList = new ArrayList&lt;String&gt;();
  try {
      SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd");
      int[] fromDateParts = new int[3];
      for (int f = 0; f &lt; fromIsoDate.split("-").length; f++) {
          fromDateParts[f] = Integer.parseInt(fromIsoDate.split("-")[f]);
          System.out.println("fromDateParts[" + f + "] : " + fromDateParts[f]);
      }
      int[] toDateParts = new int[3];
      for (int t = 0; t &lt; toIsoDate.split("-").length; t++) {
          toDateParts[t] = Integer.parseInt(toIsoDate.split("-")[t]);
          System.out.println("toDateParts[" + t + "] : " + toDateParts[t]);
      }
      Calendar fromDate = new GregorianCalendar(fromDateParts[0], fromDateParts[1], fromDateParts[2]);
      Calendar toDate = new GregorianCalendar(toDateParts[0], toDateParts[1], toDateParts[2]);
      System.out.println("fromDate " + fromDate + " toDate " + toDate);
      boolean hasMoreDays = true;
      while (hasMoreDays) {
          if ((fromDate.before(toDate)) || (fromDate.equals(toDate))) {
              datesList.add(isoFormat.format(fromDate));
              fromDate.add(Calendar.DAY_OF_MONTH, 1);
          } else {
              hasMoreDays = false;
          }
      }
  } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Exception : While determining the dates in between " + fromIsoDate + " and " + toIsoDate + "!");
  }
  </code></pre>
  
  <p>But, it throws error:<br>
  java.lang.IllegalArgumentException: Cannot format given Object as a Date.</p>
  
  <p>Please guide me in getting the list of dates between in a date range!</p>