当前位置: 首页>>代码示例>>Java>>正文


Java EventDateTime.setDate方法代码示例

本文整理汇总了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);

}
 
开发者ID:fjakop,项目名称:ngcalsync,代码行数:39,代码来源:GoogleCalendarDAO.java

示例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;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:60,代码来源:GoogleEntryToEventConverter.java

示例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);
	
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:22,代码来源:GoogleCalendarHelper.java


注:本文中的com.google.api.services.calendar.model.EventDateTime.setDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。