private static EventDateTime getEventDateTime(CalendarEventModel.CalendarEventTime dateTime) { if (dateTime == null) { return null; } EventDateTime eventDateTime = new EventDateTime(); // google's APIs want millisecond from epoch, and the timezone offset in minutes. if (dateTime.isDateOnly()) { eventDateTime.setDate(new DateTime(true, dateTime.getDateTime().toEpochSecond() * 1000, dateTime.getDateTime().getOffset().getTotalSeconds() / 60)); } else { eventDateTime.setDateTime(new DateTime( dateTime.getDateTime().toEpochSecond() * 1000, dateTime.getDateTime().getOffset().getTotalSeconds() / 60)); } return eventDateTime; }
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; }
Date startMidDate = dateFormat.parse(composedTime); DateTime start = new DateTime(startMidDate); event.setStart(new EventDateTime().setDateTime(start)); } else { composedTime = startDate; DateTime startDateTime = new DateTime(composedTime); EventDateTime startEventDateTime = new EventDateTime().setDate(startDateTime); event.setStart(startEventDateTime); Date endMidDate = dateFormat.parse(composedTime); DateTime end = new DateTime(endMidDate); event.setEnd(new EventDateTime().setDateTime(end)); } else { composedTime = endDate; DateTime endDateTime = new DateTime(composedTime); EventDateTime endEventDateTime = new EventDateTime().setDate(endDateTime); event.setEnd(endEventDateTime);
Date startMidDate = dateFormat.parse(composedTime); DateTime start = new DateTime(startMidDate); event.setStart(new EventDateTime().setDateTime(start)); } else { composedTime = startDate; DateTime startDateTime = new DateTime(composedTime); EventDateTime startEventDateTime = new EventDateTime().setDate(startDateTime); event.setStart(startEventDateTime); Date endMidDate = dateFormat.parse(composedTime); DateTime end = new DateTime(endMidDate); event.setEnd(new EventDateTime().setDateTime(end)); } else { composedTime = endDate; DateTime endDateTime = new DateTime(composedTime); EventDateTime endEventDateTime = new EventDateTime().setDate(endDateTime); event.setEnd(endEventDateTime);
private static EventDateTime convertToEventDateTime(final org.joda.time.DateTime date, final boolean isAllDay, final DateTimeZone calendarTimeZone) { final EventDateTime result = new EventDateTime(); if (isAllDay) { result.setDate(convertToDate(date, calendarTimeZone.getOffset(date.getMillis()))); } else { result.setDateTime(convertToDateTime(date)); } result.setTimeZone(calendarTimeZone.getID()); return result; }
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); }
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
event.setDescription(body.getString("description")); EventDateTime start = new EventDateTime(); start.setDateTime(new DateTime(body.getLong("epochStart"))); event.setStart(start.setTimeZone(cal.getTimeZone())); EventDateTime end = new EventDateTime(); end.setDateTime(new DateTime(body.getLong("epochEnd"))); event.setEnd(end.setTimeZone(cal.getTimeZone()));
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())));