com.google.api.services.calendar.model.Event类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(14.8k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中com.google.api.services.calendar.model.Event类的一些代码示例,展示了Event类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event类的具体详情如下:
包路径:com.google.api.services.calendar.model.Event
类名称:Event

Event介绍

暂无

代码示例

代码示例来源:origin: google/data-transfer-project

static Event convertToGoogleCalendarEvent(CalendarEventModel eventModel) {
 Event event = new Event()
   .setLocation(eventModel.getLocation())
   .setDescription(eventModel.getTitle())
   .setSummary(eventModel.getNotes())
   .setStart(getEventDateTime(eventModel.getStartTime()))
   .setEnd(getEventDateTime(eventModel.getEndTime()));
 if (eventModel.getAttendees() != null) {
  event.setAttendees(eventModel.getAttendees().stream()
    .map(GoogleCalendarImporter::transformToEventAttendee)
    .collect(Collectors.toList()));
 }
 return event;
}

代码示例来源:origin: google/data-transfer-project

private static CalendarEventModel convertToCalendarEventModel(String id, Event eventData) {
 List<EventAttendee> attendees = eventData.getAttendees();
 List<String> recurrenceRulesStrings = eventData.getRecurrence();
 return new CalendarEventModel(
   id,
   eventData.getDescription(),
   eventData.getSummary(),
   attendees == null
     ? null
     : attendees
       .stream()
       .map(GoogleCalendarExporter::transformToModelAttendee)
       .collect(Collectors.toList()),
   eventData.getLocation(),
   getEventTime(eventData.getStart()),
   getEventTime(eventData.getEnd()),
   recurrenceRulesStrings == null ? null : getRecurrenceRule(recurrenceRulesStrings));
}

代码示例来源:origin: google/google-api-java-client-samples

static void display(Event event) {
  if (event.getStart() != null) {
   System.out.println("Start Time: " + event.getStart());
  }
  if (event.getEnd() != null) {
   System.out.println("End Time: " + event.getEnd());
  }
 }
}

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

com.google.api.services.calendar.model.Calendar cal = service.calendars().get(calendarData.getCalendarId()).execute();
Event event = new Event();
event.setId(KeyGenerator.generateEventId());
event.setVisibility("public");
event.setSummary(body.getString("summary"));
event.setDescription(body.getString("description"));
event.setStart(start.setTimeZone(cal.getTimeZone()));
event.setEnd(end.setTimeZone(cal.getTimeZone()));
  event.setColorId(EventColor.fromNameOrHexOrID(body.getString("color")).getId() + "");
  event.setLocation(body.getString("location"));
  event.setRecurrence(Arrays.asList(rr));
ed.setEventId(event.getId());
  ed.setEventEnd(event.getEnd().getDateTime().getValue());
respondBody.put("id", confirmed.getId());

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

public PreEvent(long _guildId, Event e) {
  guildId = _guildId;
  eventId = e.getId();
  color = EventColor.fromNameOrHexOrID(e.getColorId());
  if (e.getRecurrence() != null && e.getRecurrence().size() > 0) {
    recur = true;
    recurrence.fromRRule(e.getRecurrence().get(0));
  if (e.getSummary() != null)
    summary = e.getSummary();
  if (e.getDescription() != null)
    description = e.getDescription();
  if (e.getLocation() != null)
    location = e.getLocation();
  startDateTime = e.getStart();
  endDateTime = e.getEnd();
    if (e.getStart().getDateTime() != null) {
      viewableStartDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDateTime().getValue(), cal.getTimeZone())));
      viewableEndDate = new EventDateTime().setDateTime(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDateTime().getValue(), cal.getTimeZone())));
    } else {
      viewableStartDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getStart().getDate().getValue(), cal.getTimeZone())));
      viewableEndDate = new EventDateTime().setDate(new DateTime(TimeUtils.applyTimeZoneOffset(e.getEnd().getDate().getValue(), cal.getTimeZone())));

代码示例来源:origin: io.syndesis.connector/connector-google-calendar

if (ObjectHelper.isNotEmpty(event.getSummary())) {
  model.setTitle(event.getSummary());
if (ObjectHelper.isNotEmpty(event.getDescription())) {
  model.setDescription(event.getDescription());
if (ObjectHelper.isNotEmpty(event.getAttendees())) {
  model.setAttendees(getAttendeesString(event.getAttendees()));
if (ObjectHelper.isNotEmpty(event.getStart())) {
  if (event.getStart().getDateTime() != null) {
    model.setStartDate(dateFormat.format(new Date(event.getStart().getDateTime().getValue())));
    model.setStartTime(timeFormat.format(new Date(event.getStart().getDateTime().getValue())));
  } else {
    model.setStartDate(dateFormat.format(new Date(event.getStart().getDate().getValue())));
if (ObjectHelper.isNotEmpty(event.getEnd())) {
  if (event.getEnd().getDateTime() != null) {
    model.setEndDate(dateFormat.format(new Date(event.getEnd().getDateTime().getValue())));
    model.setEndTime(timeFormat.format(new Date(event.getEnd().getDateTime().getValue())));
  } else {
    model.setEndDate(dateFormat.format(new Date(event.getEnd().getDate().getValue())));
if (ObjectHelper.isNotEmpty(event.getLocation())) {
  model.setLocation(event.getLocation());
if (ObjectHelper.isNotEmpty(event.getId())) {
  model.setEventId(event.getId());

代码示例来源:origin: gdenning/exchange-sync

private AppointmentDto convertToAppointmentDto(final Event event) {
  final GoogleAppointmentDto result = new GoogleAppointmentDto();
  result.setGoogleId(event.getId());
  if (event.getExtendedProperties() != null && event.getExtendedProperties().getPrivate() != null) {
    result.setExchangeId(event.getExtendedProperties().getPrivate().get(EXT_PROPERTY_EXCHANGE_ID));
  result.setLastModified(convertToJodaDateTime(event.getUpdated()));
  result.setSummary(event.getSummary());
  result.setDescription(event.getDescription());
  result.setStart(convertToJodaDateTime(event.getStart()));
  result.setEnd(convertToJodaDateTime(event.getEnd()));
  if (event.getEnd().getDateTime() != null) {
    result.setAllDay(event.getEnd().getDateTime().isDateOnly());
  result.setLocation(event.getLocation());
  if (event.getOrganizer() != null) {
    final PersonDto person = new PersonDto();
    person.setName(event.getOrganizer().getDisplayName());
    person.setEmail(event.getOrganizer().getEmail());
    result.setOrganizer(person);
  if (event.getAttendees() != null) {
    final Set<PersonDto> attendees = new HashSet<PersonDto>();
    for (final EventAttendee eventAttendee : event.getAttendees()) {
      final PersonDto person = new PersonDto();
      person.setName(eventAttendee.getDisplayName());
  if (event.getReminders() != null && event.getReminders().getOverrides() != null) {
    final EventReminder reminder = event.getReminders().getOverrides().iterator().next();
    result.setReminderMinutesBeforeStart(reminder.getMinutes());

代码示例来源:origin: gdenning/exchange-sync

private void populateEventFromAppointmentDto(final AppointmentDto appointmentDto, final Event event) {
  event.setSummary(appointmentDto.getSummary());
  event.setDescription(appointmentDto.getDescription());
  event.setStart(convertToEventDateTime(appointmentDto.getStart(), appointmentDto.isAllDay(), calendarTimeZone));
  event.setEnd(convertToEventDateTime(appointmentDto.getEnd(), appointmentDto.isAllDay(), calendarTimeZone));
  event.setLocation(appointmentDto.getLocation());
  if (syncOrganizerAndAttendees) {
    if (appointmentDto.getOrganizer() != null && appointmentDto.getOrganizer().getEmail() != null) {
      organizer.setDisplayName(appointmentDto.getOrganizer().getName());
      organizer.setEmail(obfuscateEmail(appointmentDto.getOrganizer().getEmail()));
      event.setOrganizer(organizer);
      event.setAttendees(attendees);
    reminders.setUseDefault(false);
    reminders.setOverrides(Collections.singletonList(reminder));
    event.setReminders(reminders);
    event.setRecurrence(Collections.singletonList(recurrencePattern));

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

for (Event e: items) {
  JSONObject jo = new JSONObject();
  jo.put("id", e.getId());
  jo.put("epochStart", e.getStart().getDateTime().getValue());
  jo.put("epochEnd", e.getEnd().getDateTime().getValue());

代码示例来源:origin: google/google-api-java-client-samples

private static Event newEvent() {
 Event event = new Event();
 event.setSummary("New Event");
 Date startDate = new Date();
 Date endDate = new Date(startDate.getTime() + 3600000);
 DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
 event.setStart(new EventDateTime().setDateTime(start));
 DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
 event.setEnd(new EventDateTime().setDateTime(end));
 return event;
}

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

public static PreEvent copyEvent(long guildId, Event event) {
    PreEvent pe = new PreEvent(guildId);
    pe.setSummary(event.getSummary());
    pe.setDescription(event.getDescription());
    pe.setLocation(event.getLocation());
    if (event.getColorId() != null)
      pe.setColor(EventColor.fromNameOrHexOrID(event.getColorId()));
    else
      pe.setColor(EventColor.RED);

    pe.setEventData(DatabaseManager.getManager().getEventData(guildId, event.getId()));

    return pe;
  }
}

代码示例来源:origin: synyx/urlaubsverwaltung

private static void fillEvent(Absence absence, Event event) {
  event.setSummary(absence.getEventSubject());
  EventAttendee eventAttendee = new EventAttendee();
  eventAttendee.setEmail(absence.getPerson().getEmail());
  eventAttendee.setDisplayName(absence.getPerson().getNiceName());
  event.setAttendees(Collections.singletonList(eventAttendee));
  EventDateTime startEventDateTime;
  EventDateTime endEventDateTime;
  if (absence.isAllDay()) {
    // To create an all-day event, you must use setDate() having created DateTime objects using a String
    DateFormat dateFormat = new SimpleDateFormat(DATE_PATTERN_YYYY_MM_DD);
    String startDateStr = dateFormat.format(absence.getStartDate());
    String endDateStr = dateFormat.format(absence.getEndDate());
    DateTime startDateTime = new DateTime(startDateStr);
    DateTime endDateTime = new DateTime(endDateStr);
    startEventDateTime = new EventDateTime().setDate(startDateTime);
    endEventDateTime = new EventDateTime().setDate(endDateTime);
  } else {
    DateTime dateTimeStart = new DateTime(absence.getStartDate());
    DateTime dateTimeEnd = new DateTime(absence.getEndDate());
    startEventDateTime = new EventDateTime().setDateTime(dateTimeStart);
    endEventDateTime = new EventDateTime().setDateTime(dateTimeEnd);
  }
  event.setStart(startEventDateTime);
  event.setEnd(endEventDateTime);
}

代码示例来源:origin: synyx/urlaubsverwaltung

@Override
public Optional<String> add(Absence absence, CalendarSettings calendarSettings) {
  googleCalendarClient = getOrCreateGoogleCalendarClient();
  if (googleCalendarClient != null) {
    GoogleCalendarSettings googleCalendarSettings =
        settingsService.getSettings().getCalendarSettings().getGoogleCalendarSettings();
    String calendarId = googleCalendarSettings.getCalendarId();
    try {
      Event eventToCommit = new Event();
      fillEvent(absence, eventToCommit);
      Event eventInCalendar = googleCalendarClient.events().insert(calendarId, eventToCommit).execute();
      LOG.info(String.format("Event %s for '%s' added to calendar '%s'.", eventInCalendar.getId(),
          absence.getPerson().getNiceName(), eventInCalendar.getSummary()));
      return Optional.of(eventInCalendar.getId());
    } catch (IOException ex) {
      LOG.warn(String.format("An error occurred while trying to add appointment to calendar %s", calendarId), ex);
      mailService.sendCalendarSyncErrorNotification(calendarId, absence, ex.toString());
    }
  }
  return Optional.empty();
}

代码示例来源:origin: gsuitedevs/java-samples

public static void main(String... args) throws IOException, GeneralSecurityException {
    // Build a new authorized API client service.
    final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
    Calendar service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
        .setApplicationName(APPLICATION_NAME)
        .build();

    // List the next 10 events from the primary calendar.
    DateTime now = new DateTime(System.currentTimeMillis());
    Events events = service.events().list("primary")
        .setMaxResults(10)
        .setTimeMin(now)
        .setOrderBy("startTime")
        .setSingleEvents(true)
        .execute();
    List<Event> items = events.getItems();
    if (items.isEmpty()) {
      System.out.println("No upcoming events found.");
    } else {
      System.out.println("Upcoming events");
      for (Event event : items) {
        DateTime start = event.getStart().getDateTime();
        if (start == null) {
          start = event.getStart().getDate();
        }
        System.out.printf("%s (%s)\n", event.getSummary(), start);
      }
    }
  }
}

代码示例来源:origin: google/data-transfer-project

new CalendarEventModel(modelCalendarId, null, null, null, null, null, null, null);
Event eventToInsert = GoogleCalendarImporter.convertToGoogleCalendarEvent(eventModel);
Event responseEvent = new Event();

代码示例来源:origin: org.apache.camel/camel-google-calendar

public Exchange createExchange(ExchangePattern pattern, Event event) {
    Exchange exchange = super.createExchange(pattern);
    Message message = exchange.getIn();
    message.setBody(event);
    message.setHeader(GoogleCalendarStreamConstants.EVENT_ID, event.getId());
    return exchange;
  }
}

代码示例来源:origin: gdenning/exchange-sync

@Override
public void addAppointment(final AppointmentDto appointment) throws IOException {
  final Event event = new Event();
  final Map<String, String> privateProperties = new HashMap<String, String>();
  privateProperties.put(EXT_PROPERTY_EXCHANGE_ID, appointment.getExchangeId());
  final ExtendedProperties extProperties = new ExtendedProperties();
  extProperties.setPrivate(privateProperties);
  event.setExtendedProperties(extProperties);
  populateEventFromAppointmentDto(appointment, event);
  client.events().insert(calendarId, event).execute();
  LOG.info("Added Google appointment " + appointment.getSummary());
}

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

private static boolean inPast(Event event) {
  if (event.getStart().getDateTime() != null)
    return event.getStart().getDateTime().getValue() <= System.currentTimeMillis();
  else
    return event.getStart().getDate().getValue() <= System.currentTimeMillis();
}

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

com.google.api.services.calendar.model.Calendar cal = service.calendars().get(calendarData.getCalendarId()).execute();
Event event = new Event();
event.setId(KeyGenerator.generateEventId());
event.setVisibility("public");
event.setSummary(body.getString("summary"));
event.setDescription(body.getString("description"));
event.setStart(start.setTimeZone(cal.getTimeZone()));
event.setEnd(end.setTimeZone(cal.getTimeZone()));
  event.setColorId(EventColor.fromNameOrHexOrID(body.getString("color")).getId() + "");
  event.setLocation(body.getString("location"));
  event.setRecurrence(Arrays.asList(rr));
ed.setEventId(event.getId());
  ed.setEventEnd(event.getEnd().getDateTime().getValue());
respondBody.put("id", confirmed.getId());

代码示例来源:origin: NovaFox161/DisCal-Discord-Bot

for (Event e : items) {
  JSONObject jo = new JSONObject();
  jo.put("id", e.getId());
  jo.put("epochStart", e.getStart().getDateTime().getValue());
  jo.put("epochEnd", e.getEnd().getDateTime().getValue());
  jo.put("timezone", tz);
  jo.put("summary", e.getSummary());
  jo.put("description", e.getDescription());
  if (e.getLocked() != null)
    jo.put("location", e.getLocation());
  else
    jo.put("location", "N/a");
  jo.put("color", EventColor.fromNameOrHexOrID(e.getColorId()).name());
  jo.put("isParent", !(e.getId().contains("_")));
  if (e.getRecurrence() != null && e.getRecurrence().size() > 0) {
    jo.put("recur", true);
    Recurrence r = new Recurrence().fromRRule(e.getRecurrence().get(0));
  EventData ed = DatabaseManager.getManager().getEventData(settings.getGuildID(), e.getId());

相关文章