Android 日历“dtStart”返回未知值
如何获取日历条目日期? dtStart 返回未知值,这不是我的事件条目日期。
eventUri = Uri.parse("content://com.android.calendar/events");
Cursor cursor = this.getContentResolver().query(eventUri, null, null, null, null);
while(cursor.moveToNext()) {
int eventCol = cursor.getColumnIndex("title");
int dateCol = cursor.getColumnIndex("dtStart");
System.out.println("Event: " + cursor.getString(eventCol)
+ "; Date of Event: " + cursor.getString(dateCol));
}
输出:
事件:项目会议;活动日期:1304236800000
如果有人可以提供帮助,我将不胜感激。谢谢
***问题解决了。我需要将时间戳转换为可读的日期格式
Date date = new Date (date);
SimpleDateFormat dateFormat = new SimpleDateFormat ("E-dd-MMM:HH:mm:ss-yyyy");
dateFormat.format(date);
How to get calendar entries date? dtStart returns me unknown value which is not my event entries date.
eventUri = Uri.parse("content://com.android.calendar/events");
Cursor cursor = this.getContentResolver().query(eventUri, null, null, null, null);
while(cursor.moveToNext()) {
int eventCol = cursor.getColumnIndex("title");
int dateCol = cursor.getColumnIndex("dtStart");
System.out.println("Event: " + cursor.getString(eventCol)
+ "; Date of Event: " + cursor.getString(dateCol));
}
OUTPUT:
Event: PROJECT MEETING ; Date of event: 1304236800000
Would appreciate if anyone can help. Thank you
***Problem is solved. I need to convert the timestamp to readable Date format
Date date = new Date (date);
SimpleDateFormat dateFormat = new SimpleDateFormat ("E-dd-MMM:HH:mm:ss-yyyy");
dateFormat.format(date);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是未知时间,而是 UNIX 时间戳,建议此处进行转换。
This is not unknown time, but UNIX timestamp, conversion is proposed here.