I wrote a simple code to insert an all day event into the calendar, using the tutorial from the official site. http://developer.android.com/guide/topics/providers/calendar-provider.html
ContentResolver cr = context.getContentResolver();
ContentValues values = new ContentValues();
values.put(Events.DTSTART, dueDate.getTime());
values.put(Events.ALL_DAY, true);
values.put(Events.DTEND, dueDate.getTime());
values.put(Events.TITLE, "Some Event");
values.put(Events.CALENDAR_ID, mCalID);
TimeZone tz = TimeZone.getDefault();
values.put(Events.EVENT_TIMEZONE, tz.getID());
Uri uri = cr.insert(Events.CONTENT_URI, values);
I found that when I opened the Google Calendar app on the my Acer device running 4.03, the date entered had been shifted back by 1 day. My local timezone is Sydney which is GMT+10.
So I went to settings changed the local time zone to American Eastern (GMT -5) and ran the same code and there was no shift in the dates. Then I changed the timezone to GMT+2, Istanbul and there was a shift in the dates. Then I changed to London GMT 0, and there was no shift.
When I did non all day events the correct times were entered into the calendar regardless of the timezone.
The closest bug report I found was this http://code.google.com/p/android/issues/detail?id=14051
Am I missing something in the code, or have others also encountered this.
Edit On further inspection when reading Event data using content resolver
ContentResolver cr = context.getContentResolver();
Uri uri = CalendarContract.Events.CONTENT_URI;
String selection =CalendarContract.Events._ID + "=?";
String [] selectionArgs = new String[]{String.valueOf(eventID)};
The value of the