title: get startday of month and endday of month using calendar class in Java
body: <p>Given a year and a month; I want to get two <code>Date Objects</code>. one for <code>startDate</code> of the month and one for the <code>end Date</code> of the month. I have it implemented here and it works. but this looks too verbose, and I am wondering if there is a neat solution to this; </p>
  
  <p>Eg given March 2014,
  start Date will be March 01 and end Date will be March 31 ( as <code>Date objects</code> with millisecond precision) </p>
  
  <pre><code>public setDates(int month,int year) {
  
          Calendar calendar = Calendar.getInstance();
  
  
          // Use the calendar to get the startDate and endDate of this Invoice.
          calendar.set(Calendar.YEAR, year);
          calendar.set(Calendar.MONTH,month);
  
          //set start date
          calendar.set(Calendar.DAY_OF_MONTH,
                       calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
          calendar.set(Calendar.HOUR_OF_DAY,
                       calendar.getActualMinimum(Calendar.HOUR_OF_DAY));
          calendar.set(Calendar.MINUTE,
                       calendar.getActualMinimum(Calendar.MINUTE));
          calendar.set(Calendar.SECOND,
                       calendar.getActualMinimum(Calendar.SECOND));
          calendar.set(Calendar.MILLISECOND,
                       calendar.getActualMinimum(Calendar.MILLISECOND));
          this.startDate = calendar.getTime();
  
          //endDate start date
          calendar.set(Calendar.DAY_OF_MONTH,
                       calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
          calendar.set(Calendar.HOUR_OF_DAY,
                       calendar.getActualMaximum(Calendar.HOUR_OF_DAY));
          calendar.set(Calendar.MINUTE,
                       calendar.getActualMaximum(Calendar.MINUTE));
          calendar.set(Calendar.SECOND,
                       calendar.getActualMaximum(Calendar.SECOND));
          calendar.set(Calendar.MILLISECOND,
                       calendar.getActualMaximum(Calendar.MILLISECOND));
          this.endDate = calendar.getTime();
  }
  </code></pre>