How to get event start time from android calendar

How to get StartTime and EndTime from an event from an Android calendar ? I use this code to get all event data, but it gives me StartDate and EndDate , but I need Date + Time both Start and End . here is the code

 CalNames[i] = "Event" + cursor_event.getInt(0) + ": \nTitle: " + cursor_event.getString(1) + "\nDescription: " + cursor_event.getString(2) + "\nStart Date: " + new Date(cursor_event.getLong(3)) + "\nEnd Date : " + new Date(cursor_event.getLong(4)) + "\nLocation : " + cursor_event.getString(5); 
+4
source share
1 answer

Use cursor_event.getLong(cursor_event.getColumnIndex("dtstart")) to get the time when the event starts in UTC milliseconds from the era.

To get the session end time, use cursor_event.getLong(cursor_event.getColumnIndex("dtend"))

All event columns you can find here http://developer.android.com/reference/android/provider/CalendarContract.EventsColumns.html#DTEND

+1
source

Source: https://habr.com/ru/post/1443994/


All Articles