I want to add an event in android calendar from my application. I have added the event in calendar by using the following code.
Calendar c = Calendar.getInstance();
date2 = formatter.parse(eDate);
c.setTime(date2);
c.add(Calendar.HOUR, 1);
eDate = formatter.format(c.getTime());
date2 = formatter.parse(eDate);
date2 = formatter.parse(eDate);
c.setTime(date2);
eDate = formatter.format(c.getTime());
cal1=Calendar.getInstance();
cal1.setTime(date1);
cal2=Calendar.getInstance();
cal2.setTime(date2);
calEvent.put("dtstart", cal1.getTimeInMillis());
calEvent.put("dtend", cal2.getTimeInMillis());
String timeZone = TimeZone.getDefault().getID();
calEvent.put("eventTimezone", timeZone);
Uri uri = contentResolver.insert(Uri.parse("content://com.android.calendar/events"),
calEvent);
date2 = formatter.parse(eDate);
I need to add one hour to the calendar. So I have added 1 hour to the end date, using the code :
c.add(Calendar.HOUR, 1);
But when I look at in the calendar, it is showing 12 hour event. That means that if a added an event for 10 PM tomorrow, it creates an event from 10 PM tomorrow to 10AM tomorrow.
Can anybody tell me how to add an event that starts at 10 PM tomorrow and ends at 11 PM tomorrow?