title: Get last day of Month
body: <p>For getting last date of month I have written this function</p>
  
  <pre><code>/**
   * @param month integer value of month
   * @param year integer value of month
   * @return last day of month in MM/dd/YYYY format
   */
  private static String getDate(int month, int year) {
      Calendar calendar = Calendar.getInstance();
      // passing month-1 because 0--&gt;jan, 1--&gt;feb... 11--&gt;dec
      calendar.set(year, month - 1, 1);
      calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
      Date date = calendar.getTime();
      DateFormat DATE_FORMAT = new SimpleDateFormat("MM/dd/YYYY");
      return DATE_FORMAT.format(date);
  }
  </code></pre>
  
  <p>for all the inputs its working fine with one exception when the month is December, i.e. getDate(12, 2012) returns 12/31/2013 but it should return 12/31/2012.
  Please explain the behavior and solution too. </p>