Java Code Examples for com.google.api.services.calendar.model.Event#getId()
The following examples show how to use
com.google.api.services.calendar.model.Event#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleCalendar.java From garoon-google with MIT License | 6 votes |
public String addSchedule(Date start, Date end, String title, String description, String location, String color, ArrayList<String> recurrence, TimeZone timezone) throws Exception { String id = null; Event googleSchedule = new Event(); googleSchedule.setStart(new EventDateTime().setTimeZone(timezone.getID()).setDateTime(new DateTime(start))); googleSchedule.setEnd(new EventDateTime().setTimeZone(timezone.getID()).setDateTime(new DateTime(end))); googleSchedule.setRecurrence(null); googleSchedule.setSummary(title.trim()); googleSchedule.setDescription(description.trim()); googleSchedule.setLocation(location.trim()); googleSchedule.setColorId(color); googleSchedule.setRecurrence(recurrence); Event createdEvent = this.CALENDAR.events().insert(this.CALENDAR_NAME, googleSchedule).execute(); id = createdEvent.getId(); return id; }
Example 2
Source File: PreEvent.java From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 | 4 votes |
public PreEvent(Snowflake _guildId, Event e) { guildId = _guildId; eventId = e.getId(); color = EventColor.fromNameOrHexOrID(e.getColorId()); recurrence = new Recurrence(); 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(); //Here is where I need to fix the display times GuildSettings settings = DatabaseManager.getManager().getSettings(guildId); //TODO: Support multiple calendars CalendarData data = DatabaseManager.getManager().getMainCalendar(guildId); Calendar cal = null; try { cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute(); } catch (Exception ex) { Logger.getLogger().exception(null, "Failed to get proper date time for event!", ex, true, this.getClass()); } if (cal != null) { //Check if either DateTime or just Date... if (e.getStart().getDateTime() != null) { //DateTime 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 { //Just Date 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()))); } } else { //Almost definitely not correct, but we need something displayed here. viewableStartDate = e.getStart(); viewableEndDate = e.getEnd(); } eventData = DatabaseManager.getManager().getEventData(guildId, e.getId()); editing = false; lastEdit = System.currentTimeMillis(); }
Example 3
Source File: PreEvent.java From DisCal-Discord-Bot with GNU Lesser General Public License v3.0 | 4 votes |
public PreEvent(Snowflake _guildId, Event e) { guildId = _guildId; eventId = e.getId(); color = EventColor.fromNameOrHexOrID(e.getColorId()); recurrence = new Recurrence(); 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(); //Here is where I need to fix the display times GuildSettings settings = DatabaseManager.getManager().getSettings(guildId); //TODO: Support multiple calendars CalendarData data = DatabaseManager.getManager().getMainCalendar(guildId); Calendar cal = null; try { cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute(); } catch (Exception ex) { Logger.getLogger().exception(null, "Failed to get proper date time for event!", ex, true, this.getClass()); } if (cal != null) { //Check if either DateTime or just Date... if (e.getStart().getDateTime() != null) { //DateTime 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 { //Just Date 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()))); } } else { //Almost definitely not correct, but we need something displayed here. viewableStartDate = e.getStart(); viewableEndDate = e.getEnd(); } eventData = DatabaseManager.getManager().getEventData(guildId, e.getId()); editing = false; lastEdit = System.currentTimeMillis(); }