【发布时间】:2016-04-28 06:35:55
【问题描述】:
在 Android 应用程序中,我将事件添加到用户的日历中。
我的问题是,我保存的时间发生了变化,当它存储在 Google 日历中时(意味着 +0500 的 03:00 到 08:00 偏移添加到我的时区 +0500 的时间)
请指导我做错了什么..
我正在使用此代码来设置日历活动的时间和日期
calendar.set(year, monthOfYear, dayOfMonth);
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
calendar.set(Calendar.MINUTE, minute);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
DateTime startDateTime = new DateTime(sdf.format(calendar.getTime()));
EventDateTime start = new EventDateTime().setDateTime(startDateTime);
event.setStart(start);
详细参考原代码: https://developers.google.com/google-apps/calendar/create-events
【问题讨论】:
标签: android datetime google-calendar-api simpledateformat