Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get the start time and end time from calendar events in android?
    primarykey
    data
    text
    <p>I want to get the start time and end time of the calendar event in android?How can i achive it?</p> <p>This is my code,</p> <pre><code>public static void readCalendarEvent(Context context) throws ParseException { ContentResolver contentResolver = context.getContentResolver(); Calendar calendar = Calendar.getInstance(); String dtstart = "dtstart"; String dtend = "dtend"; SimpleDateFormat displayFormatter = new SimpleDateFormat(" MMMM dd, yyyy (EEEE)"); stime=displayFormatter.format(calendar.getTime()); SimpleDateFormat startFormatter = new SimpleDateFormat("MM/dd/yy"); String dateString = startFormatter.format(calendar.getTime()); long after = calendar.getTimeInMillis(); SimpleDateFormat formatterr = new SimpleDateFormat("hh:mm:ss MM/dd/yy"); Calendar endOfDay = Calendar.getInstance(); Date dateCCC = formatterr.parse("47:59:59 " + dateString); endOfDay.setTime(dateCCC); cursor = contentResolver.query(Uri.parse("content://com.android.calendar/events"), (new String[] { "calendar_id", "title", "description", "dtstart", "dtend", "eventLocation" }), "(" + dtstart + "&gt;" + after + " and " + dtend + "&lt;" + endOfDay.getTimeInMillis() + ")", null, "dtstart ASC"); gCalendar = new ArrayList&lt;GoogleCalendar&gt;(); try { System.out.println("Count=" + cursor.getCount()); if (cursor.getCount() &gt; 0) { System.out.println("the control is just inside of the cursor.count loop"); while (cursor.moveToNext()) { GoogleCalendar googleCalendar = new GoogleCalendar(); gCalendar.add(googleCalendar); int calendar_id = cursor.getInt(0); googleCalendar.setCalendar_id(calendar_id); String title = cursor.getString(1); googleCalendar.setTitle(title); String description = cursor.getString(2); googleCalendar.setDescription(description); String dtstart1 = cursor.getString(3); googleCalendar.setDtstart(dtstart1); System.out.println("Starting date is :" +dtstart1); String dtend1 = cursor.getString(4); googleCalendar.setDtend(dtend1); String eventlocation = cursor.getString(5); googleCalendar.setEventlocation(eventlocation); } } } catch (AssertionError ex) { ex.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>The code is working fine but, I want to get the start time end time from this code.I can i achieve it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload