本文整理汇总了Java中com.google.api.services.calendar.model.EventDateTime类的典型用法代码示例。如果您正苦于以下问题:Java EventDateTime类的具体用法?Java EventDateTime怎么用?Java EventDateTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventDateTime类属于com.google.api.services.calendar.model包,在下文中一共展示了EventDateTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSchedule
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
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;
}
示例2: insertData
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
private void insertData() throws IOException
{
final DateTime date = Date.today();
final Prayers prayers = new Prayers(context, date);
for (int i = 0; i < Prayers.COUNT; i++)
{
final String title = prayers.getEnglishName(i) + PRAYER;
final EventDateTime time = getEventTime(prayers.getDateTime(i, date));
final Event event = new Event().setSummary(title)
.setDescription("Iqama time for Islamic Center of Blacksburg")
.setStart(time).setEnd(time).setLocation("Islamic Center of Blacksburg")
.setRecurrence(getRecurrenceRule(date))
.setReminders(getReminders());
calendar.events().insert(calendarId, event).execute();
}
}
示例3: isDateOnly
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
/**
* @return {@code true} if the object contains just the date, false otherwise.
*/
private boolean isDateOnly(EventDateTime source) {
NDC.push("isDateOnly");
try {
if (source.getDate() != null && source.getDateTime() == null) {
return true;
}
if (source.getDate() == null && source.getDateTime() != null) {
return false;
}
logger.error("source: " + source);
logger.error("date: " + source.getDate());
logger.error("time: " + source.getDateTime());
throw new IllegalArgumentException("API must have changed, both Date and DateTime are returned, need to revise the code");
} finally {
NDC.pop();
}
}
示例4: store
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
/**
* Creates a new Google Calendar Entry for each <code>item</code> and adds
* it to the processing queue. The entries' title will either be the items
* name or <code>alias</code> if it is <code>!= null</code>.
*
* The new Calendar Entry will contain a single command to be executed e.g.<br>
* <p>
* <code>send <item.name> <item.state></code>
* </p>
*
* @param item the item which state should be persisted.
* @param alias the alias under which the item should be persisted.
*/
@Override
public void store(final Item item, final String alias) {
if (initialized) {
String newAlias = alias != null ? alias : item.getName();
Event event = new Event();
event.setSummary("[PresenceSimulation] " + newAlias);
event.setDescription(String.format(executeScript, item.getName(), item.getState().toString()));
Date now = new Date();
Date startDate = new Date(now.getTime() + 3600000L * 24 * offset);
Date endDate = startDate;
DateTime start = new DateTime(startDate);
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate);
event.setEnd(new EventDateTime().setDateTime(end));
entries.offer(event);
logger.trace("added new entry '{}' for item '{}' to upload queue", event.getSummary(), item.getName());
} else {
logger.debug(
"GCal PresenceSimulation Service isn't initialized properly! No entries will be uploaded to your Google Calendar");
}
}
示例5: onOK
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
private void onOK() {
if(!name.getText().isEmpty()) event.setSummary(name.getText());
if(!desc.getText().isEmpty()) event.setDescription(desc.getText());
if(!location.getText().isEmpty()) event.setLocation(location.getText());
EventDateTime start = getStartTime();
EventDateTime end = getEndTime();
if(start == null || end == null) return;
if(allDayBox.isSelected()){
if(end.getDate().getValue() < start.getDate().getValue()){
JOptionPane.showMessageDialog(this, "The end date is before the start date.", "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
}
else{
if(end.getDateTime().getValue() <= start.getDateTime().getValue()){
JOptionPane.showMessageDialog(this, "The end date is before the start date.", "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
}
event.setStart(start);
event.setEnd(end);
try{
Program.calendars.updateEvent(jCalendar.getCalender(), event);
}
catch(IOException e){
JOptionPane.showMessageDialog(this, "Error updating event: " + e.getMessage(), "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
dispose();
}
示例6: onOK
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
private void onOK() {
Event e = new Event();
if(name.getText().isEmpty()){
JOptionPane.showMessageDialog(this, "The event must have a title.", "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
e.setSummary(name.getText());
if(!desc.getText().isEmpty()) e.setDescription(desc.getText());
EventDateTime start = getStartTime();
EventDateTime end = getEndTime();
if(start == null || end == null) return;
if(allDayBox.isSelected()){
if(end.getDate().getValue() < start.getDate().getValue()){
JOptionPane.showMessageDialog(this, "The end date is before the start date.", "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
}
else{
if(end.getDateTime().getValue() <= start.getDateTime().getValue()){
JOptionPane.showMessageDialog(this, "The end date is before the start date.", "EVE Calendars", JOptionPane.ERROR_MESSAGE);
return;
}
}
e.setStart(start);
e.setEnd(end);
event = e;
dispose();
}
示例7: newEvent
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
public Event newEvent(final String summary, final LocalDate date, final String description) {
final Event event = new Event();
event.setSummary(summary);
event.setDescription("Dr.Bookings:\n" + description);
final Date startDate = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
final Date endDate = new Date(startDate.getTime() + 86400000); // An
// all-day
// event
// is 1
// day
// (or
// 86400000
// ms)
// long
final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
final String startDateStr = dateFormat.format(startDate);
final String endDateStr = dateFormat.format(endDate);
// Out of the 6 methods for creating a DateTime object with no time
// element, only the String version works
final DateTime startDateTime = new DateTime(startDateStr);
final DateTime endDateTime = new DateTime(endDateStr);
// Must use the setDate() method for an all-day event (setDateTime() is
// used for timed events)
final EventDateTime startEventDateTime = new EventDateTime().setDate(startDateTime);
final EventDateTime endEventDateTime = new EventDateTime().setDate(endDateTime);
event.setStart(startEventDateTime);
event.setEnd(endEventDateTime);
return event;
}
示例8: testInsert
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
@Test
public void testInsert() throws Exception {
Event event = new Event();
event.setSummary("Feed the Camel");
event.setLocation("Somewhere");
ArrayList<EventAttendee> attendees = new ArrayList<EventAttendee>();
attendees.add(new EventAttendee().setEmail("[email protected]"));
event.setAttendees(attendees);
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));
final Map<String, Object> headers = new HashMap<String, Object>();
// parameter type is String
headers.put("CamelGoogleCalendar.calendarId", getCalendar().getId());
// parameter type is com.google.api.services.calendar.model.Event
headers.put("CamelGoogleCalendar.content", event);
final com.google.api.services.calendar.model.Event result = requestBodyAndHeaders("direct://INSERT", null, headers);
assertEquals("Feed the Camel", result.getSummary());
LOG.debug("insert: " + result);
}
示例9: createTestEvent
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
/** Creates a test event. */
public static Event createTestEvent(Calendar client, String summary) throws IOException {
Date oneHourFromNow = Utils.getRelativeDate(java.util.Calendar.HOUR, 1);
Date twoHoursFromNow = Utils.getRelativeDate(java.util.Calendar.HOUR, 2);
DateTime start = new DateTime(oneHourFromNow, TimeZone.getTimeZone("UTC"));
DateTime end = new DateTime(twoHoursFromNow, TimeZone.getTimeZone("UTC"));
Event event = new Event().setSummary(summary)
.setReminders(new Reminders().setUseDefault(false))
.setStart(new EventDateTime().setDateTime(start))
.setEnd(new EventDateTime().setDateTime(end));
return client.events().insert("primary", event).execute();
}
示例10: 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);
}
示例11: fillEvent
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
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);
}
示例12: PreEvent
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
public PreEvent(long _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 {
if (settings.useExternalCalendar()) {
cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();
} else {
cal = CalendarAuth.getCalendarService().calendars().get(data.getCalendarAddress()).execute();
}
} catch (Exception ex) {
ExceptionHandler.sendException(null, "Failed to get proper date time for event!", ex, 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();
}
示例13: moduleEndDate
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
private void moduleEndDate(String[] args, MessageReceivedEvent event, GuildSettings settings) {
long guildId = event.getGuild().getLongID();
if (args.length == 2) {
if (EventCreator.getCreator().hasPreEvent(guildId)) {
String dateRaw = args[1].trim();
if (dateRaw.length() > 10) {
try {
//Do a lot of date shuffling to get to proper formats and shit like that.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss");
TimeZone tz = TimeZone.getTimeZone(EventCreator.getCreator().getPreEvent(guildId).getTimeZone());
sdf.setTimeZone(tz);
Date dateObj = sdf.parse(dateRaw);
DateTime dateTime = new DateTime(dateObj);
EventDateTime eventDateTime = new EventDateTime();
eventDateTime.setDateTime(dateTime);
//Wait! Lets check now if its in the future and not the past!
if (!TimeUtils.inPast(dateRaw, tz) && !TimeUtils.endBeforeStart(dateRaw, tz, EventCreator.getCreator().getPreEvent(guildId))) {
//Date shuffling done, now actually apply all that damn stuff here.
EventCreator.getCreator().getPreEvent(guildId).setEndDateTime(eventDateTime);
//Apply viewable date/times...
SimpleDateFormat sdfV = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss");
Date dateObjV = sdfV.parse(dateRaw);
DateTime dateTimeV = new DateTime(dateObjV);
EventDateTime eventDateTimeV = new EventDateTime();
eventDateTimeV.setDateTime(dateTimeV);
EventCreator.getCreator().getPreEvent(guildId).setViewableEndDate(eventDateTimeV);
if (EventCreator.getCreator().hasCreatorMessage(guildId)) {
Message.deleteMessage(event);
Message.deleteMessage(EventCreator.getCreator().getCreatorMessage(guildId));
EventCreator.getCreator().setCreatorMessage(Message.sendMessage(EventMessageFormatter.getPreEventEmbed(EventCreator.getCreator().getPreEvent(guildId), settings), MessageManager.getMessage("Creator.Event.End.Success.New", settings), event));
} else {
String msg = MessageManager.getMessage("Creator.Event.End.Success", settings);
msg = msg.replaceAll("%date%", EventMessageFormatter.getHumanReadableDate(eventDateTimeV, settings, true)).replaceAll("%time%", EventMessageFormatter.getHumanReadableTime(eventDateTimeV, settings, true));
Message.sendMessage(msg, event);
}
} else {
//Oops! Time is in the past or before the starting time...
if (EventCreator.getCreator().hasCreatorMessage(guildId)) {
Message.deleteMessage(event);
Message.deleteMessage(EventCreator.getCreator().getCreatorMessage(guildId));
EventCreator.getCreator().setCreatorMessage(Message.sendMessage(EventMessageFormatter.getPreEventEmbed(EventCreator.getCreator().getPreEvent(guildId), settings), MessageManager.getMessage("Creator.Event.End.Failure.Illegal", settings), event));
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Event.End.Failure.Illegal", settings), event);
}
}
} catch (ParseException e) {
if (EventCreator.getCreator().hasCreatorMessage(guildId)) {
Message.deleteMessage(event);
Message.deleteMessage(EventCreator.getCreator().getCreatorMessage(guildId));
EventCreator.getCreator().setCreatorMessage(Message.sendMessage(EventMessageFormatter.getPreEventEmbed(EventCreator.getCreator().getPreEvent(guildId), settings), MessageManager.getMessage("Creator.Event.Time.Invalid", settings), event));
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Event.Time.Invalid", settings), event);
}
}
} else {
if (EventCreator.getCreator().hasCreatorMessage(guildId)) {
Message.deleteMessage(event);
Message.deleteMessage(EventCreator.getCreator().getCreatorMessage(guildId));
EventCreator.getCreator().setCreatorMessage(Message.sendMessage(EventMessageFormatter.getPreEventEmbed(EventCreator.getCreator().getPreEvent(guildId), settings), MessageManager.getMessage("Creator.Event.Time.InvalidFormat", settings), event));
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Event.Time.InvalidFormat", settings), event);
}
}
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Event.NotInit", settings), event);
}
} else {
if (EventCreator.getCreator().hasCreatorMessage(guildId)) {
Message.deleteMessage(event);
Message.deleteMessage(EventCreator.getCreator().getCreatorMessage(guildId));
EventCreator.getCreator().setCreatorMessage(Message.sendMessage(EventMessageFormatter.getPreEventEmbed(EventCreator.getCreator().getPreEvent(guildId), settings), MessageManager.getMessage("Creator.Event.End.Specify", settings), event));
} else {
Message.sendMessage(MessageManager.getMessage("Creator.Event.End.Specify", settings), event);
}
}
}
示例14: 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;
}
示例15: getStartTime
import com.google.api.services.calendar.model.EventDateTime; //导入依赖的package包/类
private EventDateTime getStartTime(){
return EventCreator.getTime(startmonth, startday, startyear, starth, startap, allDayBox);
}