title: Why java.util.Calendar class gives incorrect date on android?
body: <p>I have Gregorian calendar instance using particular time zone. I set calendar's date to 1970-01-01. When I get year, month, day fields they are different from what I have set them to.</p>
  
  <p>If I run this code on android device it prints "1969-11-31"</p>
  
  <pre><code>    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("America/Bahia_Banderas"));
  
      cal.clear();
      cal.set(1970, 0, 1);
  
      // Should print "1970-0-1" but prints "1969-11-31"
      android.util.Log.i("date", cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DAY_OF_MONTH));
  </code></pre>
  
  <p>However, running the same code on pure Java it works as expected.</p>
  
  <pre><code>    Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("America/Bahia_Banderas"));
      cal.clear();
      cal.set(1970, 0, 1);
  
      // Prints "1970-0-1" as expected
      System.out.println(cal.get(Calendar.YEAR) + "-" + cal.get(Calendar.MONTH) + "-" + cal.get(Calendar.DAY_OF_MONTH));
  </code></pre>
  
  <p>I've read about a <a href="http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4827490" rel="nofollow">bug</a> in Calendar class which seemed to be related to my problem. I tried the workaround mentioned in the bug report but it didn't work for me. The strangest thing, however, is that the same class behaves differently on android and on pure Java. I want instance of calendar to return correct date after I set it. Do you know how to achieve that?</p>