title: java - to calculate number of weeks - with start date as MONDAY and end date as SUNDAY
body: <p>Following is the code I used to calculate the number of weeks in a Month. But actually I need number of weeks with each week's start day as MONDAY and end day as SUNDAY. For example, JANUARY, 2012 will have 5 weeks. But with the above criteria, it will have 6 weeks.<br>
  January 2012<br>
  first week - Sunday 01<br>
  second week - 2 Mon to 8 Sunday<br>
  Third week - 9 Monday to 15 Sunday<br>
  fourth week - 16 Mon to 22 Sunday<br>
  fifth week - 23 Mon to 29 Sunday<br>
  Sixth week - 30 Monday to 31 Tuesday. </p>
  
  <p>The following code gives only 5 weeks.  </p>
  
  <pre><code>public class Test { 
      public static void main(String[] args) 
      { 
          Calendar calendar = Calendar.getInstance(); 
          int year = 2012; 
          int month = Calendar.JANUARY; 
          int date = 1; 
          calendar.set(year, month, date); 
          int numOfDaysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); 
          int numOfWeeksInMonth = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); 
          System.out.println("Number of Days In Month: " + numOfDaysInMonth); 
          System.out.println("Number of Weeks In Month: " + numOfWeeksInMonth);
  
  }
  
  }
  </code></pre>
  
  <p>The output for the above code is<br>
  Number of Days In Month: 31<br>
  Number of Weeks In Month: 5  </p>
  
  <p>But I need to get the "Number of Weeks In Month:" as 6<br>
  *<em>Also I am trying to get the start date and the end date of each week in ddMMYYYY format..  *</em>
  I am still working on it.    </p>
  
  <p>Can anyone please help me in fixing this?</p>