本文整理汇总了Java中com.google.api.services.calendar.model.EventDateTime.setDate方法的典型用法代码示例。如果您正苦于以下问题:Java EventDateTime.setDate方法的具体用法?Java EventDateTime.setDate怎么用?Java EventDateTime.setDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.calendar.model.EventDateTime
的用法示例。
在下文中一共展示了EventDateTime.setDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateCalendarEventData
import com.google.api.services.calendar.model.EventDateTime; //导入方法依赖的package包/类
private void updateCalendarEventData(final CalendarEvent event, final Event googleEvent) {
googleEvent.setSummary(event.getTitle());
googleEvent.setDescription(event.getContent());
final Calendar sdt = event.getStartDateTime();
final EventDateTime startTime = new EventDateTime();
startTime.setDateTime(new DateTime(sdt.getTime(), sdt.getTimeZone()));
final Calendar edt = event.getEndDateTime();
final EventDateTime endTime = new EventDateTime();
endTime.setDateTime(new DateTime(edt.getTime(), edt.getTimeZone()));
if (event.isAllDay()) {
edt.setTimeInMillis(sdt.getTimeInMillis());
edt.add(Calendar.DAY_OF_YEAR, 1);
startTime.setDate(new DateTime(sdt.getTime()));
endTime.setDate(new DateTime(edt.getTime()));
startTime.setDateTime(null);
endTime.setDateTime(null);
}
googleEvent.setStart(startTime);
googleEvent.setEnd(endTime);
googleEvent.setLocation(event.getLocation());
final Reminders reminders = new Reminders();
final EventReminder eventReminder = new EventReminder();
eventReminder.setMinutes(new Integer(settings.getReminderMinutes()));
eventReminder.setMethod("popup"); //$NON-NLS-1$
reminders.setOverrides(Arrays.asList(eventReminder));
reminders.setUseDefault(Boolean.FALSE);
googleEvent.setReminders(reminders);
}
示例2: convert
import com.google.api.services.calendar.model.EventDateTime; //导入方法依赖的package包/类
@Override
public Event convert(GoogleEntry source) {
EventDateTime startTime = new EventDateTime();
EventDateTime endTime = new EventDateTime();
ZonedDateTime st = source.getStartAsZonedDateTime();
ZonedDateTime et = source.getEndAsZonedDateTime();
TimeZone timeZone = TimeZone.getTimeZone(source.getZoneId());
if (source.getEndTime().equals(LocalTime.MAX)) {
et = et.plusDays(1).truncatedTo(ChronoUnit.DAYS);
}
if (source.isFullDay()) {
startTime.setDate(new DateTime(true, st.toInstant().toEpochMilli(), 0));
startTime.setTimeZone(timeZone.getID());
endTime.setDate(new DateTime(true, et.toInstant().toEpochMilli(), 0));
endTime.setTimeZone(timeZone.getID());
} else {
startTime.setDateTime(new DateTime(Date.from(st.toInstant())));
startTime.setTimeZone(timeZone.getID());
endTime.setDateTime(new DateTime(Date.from(et.toInstant())));
endTime.setTimeZone(timeZone.getID());
}
Event event = new Event();
if (source.getRecurrenceRule() != null) {
List<String> recurrence = new ArrayList<>();
recurrence.add(source.getRecurrenceRule());
event.setRecurrence(recurrence);
}
Event.Reminders reminders = new Event.Reminders();
reminders.setUseDefault(source.isUseDefaultReminder());
if (source.getReminders() != null) {
List<EventReminder> overrides = new ArrayList<>();
for (GoogleEntryReminder reminder : source.getReminders()) {
EventReminder override = new EventReminder();
override.setMethod(reminder.getMethod().getId());
override.setMinutes(reminder.getMinutes());
overrides.add(override);
}
reminders.setOverrides(overrides);
}
event.setId(source.existsInGoogle() ? source.getId() : null);
event.setSummary(source.getTitle());
event.setStart(startTime);
event.setEnd(endTime);
event.setAttendees(source.getAttendees());
event.setGuestsCanModify(source.isAttendeesCanModify());
event.setGuestsCanInviteOthers(source.isAttendeesCanInviteOthers());
event.setGuestsCanSeeOtherGuests(source.isAttendeesCanSeeOthers());
event.setLocation(source.getLocation());
event.setReminders(reminders);
return event;
}
示例3: setAllDayEvent
import com.google.api.services.calendar.model.EventDateTime; //导入方法依赖的package包/类
public static void setAllDayEvent(Date date, Event event) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String startDateStr = dateFormat.format(date);
String endDateStr = dateFormat.format(new Date(date.getTime()+86400000));
// Out of the 6 methods for creating a DateTime object with no time element, only the String version works
DateTime startDateTime = new DateTime(startDateStr);
DateTime endDateTime = new DateTime(endDateStr);
EventDateTime startEventDateTime = new EventDateTime();
startEventDateTime.setDate(startDateTime);
EventDateTime endEventDateTime = new EventDateTime();
endEventDateTime.setDate(endDateTime);
event.setStart(startEventDateTime);
event.setEnd(endEventDateTime);
}