title: Setting values in calendar (java.util.Calendar)
body: <p>I'm learning the  Calendar class in Java and I am unable to understand the <code>Set(Calendar.Day OF MONTH)</code> method.  </p>
  
  <p>Here it goes:</p>
  
  <pre><code>import java.util.Calendar;  
  import java.util.Date
  
  
  public class TestCalender
  {
  
   public static void main(String[] args)
      {
  
          Calendar cal = Calendar.getInstance();
          Date date= cal.getTime();
          System.out.println(date);
          cal.set(Calendar.DAY_OF_MONTH,33);
          //cal.set(Calendar.MONTH,13);------&gt;(1)
          Date newdate = cal.getTime();
          System.out.println(newdate);
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Fri May 12 17:30:50 CDT 2017  
  Fri Jun 02 17:30:50 CDT 2017
  </code></pre>
  
  <p>When I uncomment the statement(1) the output changes to:</p>
  
  <pre><code>Fri May 12 17:33:22 CDT 2017  
  Mon Mar 05 17:33:22 CST 2018
  </code></pre>
  
  <p>Here is my question:</p>
  
  <p>I understood the change of Month to March but I'm not able to figure out why the date has changed  to 5. As per my understanding shouldn't the date be changed to April 02 2018 (when 33 days of March  is being computed since March has only 31 days the count moves to the month of April).</p>
  
  <p>I will be extremely grateful if someone could help in clearing this doubt.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Regards
  Roopa</p>