how to get start time of an event from android calendar

余生颓废 提交于 2020-01-03 19:07:35

问题


How to get StartTime and EndTime from an event from android calendar? I am using this code for get all the data of the event but it gives me StartDate and EndDate but i need Date + Time of both Start and End. here's 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);

回答1:


Use cursor_event.getLong(cursor_event.getColumnIndex("dtstart")) to get time the event starts in UTC millis since epoch.

To get event 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



来源:https://stackoverflow.com/questions/13222971/how-to-get-start-time-of-an-event-from-android-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!