title: Android Calendar API insert recurring event
body: <p>Using the <a href="http://code.google.com/apis/calendar/v3/using.html" rel="nofollow">Google Calendar Api</a>. </p>
  
  <p>After browsing the <a href="http://www.ietf.org/rfc/rfc2445" rel="nofollow">rfc2445</a>, I'm still unable to set recurrence on an event.</p>
  
  <pre><code>private String[] days = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"}; 
  private String rrule = "RRULE:FREQ=WEEKLY;WKST=MO;BYDAY=";
  private Event createdEvent;
  ...
  
  Event event = new Event();
  StringBuilder sb = new StringBuilder();
  sb.append(rrule);
  sb.append(days[startTime.get(java.util.Calendar.DAY_OF_WEEK)-1]);
  event.setSummary("HELLO WORLD");
  event.setLocation("");
  
  DateTime start = new DateTime(startTime.getTime(), TimeZone.getTimeZone("UTC"));
  event.setStart(new EventDateTime().setDateTime(start));
  DateTime end = new DateTime(endTime.getTime(), TimeZone.getTimeZone("UTC"));
  event.setEnd(new EventDateTime().setDateTime(end)); 
  
  //Setting Recurrence
  ArrayList&lt;String&gt; recur = new ArrayList&lt;String&gt;();
  recur.add(sb.toString());
  event.setRecurrence(recur);
  
  createdEvent = cal.events().insert("primary", event).execute();  //line 167
  </code></pre>
  
  <p>After running the above code, I keep receiving this error (NB: everything works if I omit specifying the recurrence, though obviously this makes the event single-occurring):</p>
  
  <pre><code>01-13 19:26:17.190: WARN/System.err(5732): com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
  01-13 19:26:17.190: WARN/System.err(5732): {
  01-13 19:26:17.190: WARN/System.err(5732):   "code" : 400,
  01-13 19:26:17.190: WARN/System.err(5732):   "errors" : [ {
  01-13 19:26:17.190: WARN/System.err(5732):     "domain" : "global",
  01-13 19:26:17.190: WARN/System.err(5732):     "message" : "Required",
  01-13 19:26:17.190: WARN/System.err(5732):     "reason" : "required"
  01-13 19:26:17.190: WARN/System.err(5732):   } ],
  01-13 19:26:17.190: WARN/System.err(5732):   "message" : "Required"
  01-13 19:26:17.190: WARN/System.err(5732): }
  01-13 19:26:17.190: WARN/System.err(5732):     at com.google.api.client.googleapis.services.GoogleClient.execute(GoogleClient.java:123)
  01-13 19:26:17.190: WARN/System.err(5732):     at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:67)
  01-13 19:26:17.190: WARN/System.err(5732):     at com.google.api.services.calendar.Calendar$Events$Insert.execute(Calendar.java:2308)
  01-13 19:26:17.190: WARN/System.err(5732):     at com.example.myproject.className.run(className.java:167)
  01-13 19:26:17.190: WARN/System.err(5732):     at java.lang.Thread.run(Thread.java:1020)
  </code></pre>
  
  <p>I manually created a recurring event in the Calendar, and made a simple method to read it in. When performing <code>event.getRecurrence</code>. The recurrence was <code>"RRULE:FREQ=WEEKLY;WKST=MO;BYDAY=MO"</code>, which accurately stated that the event that I had created is weekly recurring on a Monday.</p>
  
  <p>Can anybody spot where I'm going wrong?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Using <a href="http://code.google.com/apis/explorer/#_s=calendar&amp;_v=v3&amp;_m=events.insert&amp;calendarId=primary&amp;fields=end,recurrence,start,summary" rel="nofollow">Google's Api Explorer</a>, I manually created the JSON with the recurrence field and it worked. </p>
  
  <p>After Logging the JSON being created from <code>event</code>, it seems that the timezone isn't being passed. </p>
  
  <pre><code>{end={dateTime=2012-01-16T09:50:00.000Z}, location=, recurrence=[RRULE:FREQ=WEEKLY;], start={dateTime=2012-01-16T09:00:00.000Z}, summary=HELLO WORLD}
  </code></pre>
  
  <p>Additionally, performing <code>event.getStart().getTimeZone().toString()</code> caused <code>java.lang.NullPointerException</code>. </p>
  
  <p>Not sure why they aren't being passed ...</p>