• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Calendar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.api.services.calendar.model.Calendar的典型用法代码示例。如果您正苦于以下问题:Java Calendar类的具体用法?Java Calendar怎么用?Java Calendar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Calendar类属于com.google.api.services.calendar.model包,在下文中一共展示了Calendar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCalendarLinkEmbed

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
public static EmbedObject getCalendarLinkEmbed(Calendar cal, GuildSettings settings) {
	EmbedBuilder em = new EmbedBuilder();
	em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
	em.withAuthorName("DisCal");
	em.withTitle(MessageManager.getMessage("Embed.Calendar.Link.Title", settings));
	em.appendField(MessageManager.getMessage("Embed.Calendar.Link.Summary", settings), cal.getSummary(), true);
	try {
		em.appendField(MessageManager.getMessage("Embed.Calendar.Link.Description", settings), cal.getDescription(), true);
	} catch (NullPointerException | IllegalArgumentException e) {
		//Some error, desc probably never set, just ignore no need to log.
	}
	em.appendField(MessageManager.getMessage("Embed.Calendar.Link.TimeZone", settings), cal.getTimeZone(), false);
	em.withUrl(CalendarMessageFormatter.getCalendarLink(cal.getId()));
	em.withFooterText(MessageManager.getMessage("Embed.Calendar.Link.CalendarId", "%id%", cal.getId(), settings));
	em.withColor(56, 138, 237);

	return em.build();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:19,代码来源:CalendarMessageFormatter.java


示例2: issueCommand

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Issues the command this Object is responsible for.
 * @param args The command arguments.
 * @param event The event received.
 * @return <code>true</code> if successful, else <code>false</code>.
 */
@Override
public Boolean issueCommand(String[] args, MessageReceivedEvent event, GuildSettings settings) {
    try {
        //TODO: Handle multiple calendars...
        CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().getLongID());

        if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
            //Does not have a calendar.
            Message.sendMessage(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
        } else {
        	Calendar cal;
        	if (settings.useExternalCalendar()) {
        		cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();
} else {
	cal = CalendarAuth.getCalendarService().calendars().get(data.getCalendarAddress()).execute();
}

            Message.sendMessage(CalendarMessageFormatter.getCalendarLinkEmbed(cal, settings), event);
        }
    } catch (Exception e) {
        ExceptionHandler.sendException(event.getAuthor(), "Failed to connect to Google Cal.", e, this.getClass());
        Message.sendMessage(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
    }
    return false;
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:32,代码来源:LinkCalendarCommand.java


示例3: EventContentPane

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
EventContentPane(Calendar c, JCalendar jCal){
    cal = c;
    jCalendar = jCal;
    setLayout(new BorderLayout());
    label = new JLabel();
    edit = new JButton("Edit");
    edit.setIcon(new ImageIcon(EventContentPane.class.getResource("resources/pencil.png")));
    edit.addActionListener(e -> new EventEditor(jCalendar, event).run());
    remove = new JButton("Delete");
    remove.setIcon(new ImageIcon(EventContentPane.class.getResource("resources/trash.png")));
    remove.addActionListener(e -> deleteEvent());
    buttons = new JPanel();
    buttons.setLayout(new BorderLayout());
    buttons.add(edit, BorderLayout.WEST);
    buttons.add(remove, BorderLayout.EAST);
    add(label, BorderLayout.CENTER);
    add(buttons, BorderLayout.SOUTH);
    setVisible(false);
}
 
开发者ID:beesenpai,项目名称:EVE,代码行数:20,代码来源:EventContentPane.java


示例4: createCalendar

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Creates a new calendar with an appropriate description for a timetable
 *
 * @param timetable - the timetable to be added in the newly created calendar
 * @return the id of the calendar created
 * @throws IOException
 */
public static String createCalendar(Timetable timetable) throws IOException {
    Calendar newCalendar = new Calendar();

    String summary = timetable.getSemiGroup().equals("*") ?
            timetable.getGroup() + " Sem." + timetable.getSemester() :
            timetable.getGroup() + "/" + timetable.getSemiGroup() + " Sem." + timetable.getSemester();
    newCalendar.setSummary(summary);

    String description = "Timetable for group " + timetable.getGroup() + " for the semester " +
            timetable.getSemester() + "\n\n\tRed - Course\n\tGreen - Seminar\n\tYellow - Laboratory";
    newCalendar.setDescription(description);

    newCalendar.setTimeZone("Europe/Bucharest");

    return service.calendars().insert(newCalendar).execute().getId();
}
 
开发者ID:greenadex,项目名称:timetable-builder,代码行数:24,代码来源:TimetableBuilder.java


示例5: testCalendars

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
@Test
public void testCalendars() throws Exception {
    Calendar calendar = getCalendar();
    Calendar calendarFromGet = requestBody("direct://GET", calendar.getId());
    assertTrue(calendar.getId().equals(calendarFromGet.getId()));

    final Map<String, Object> headers = new HashMap<String, Object>();
    // parameter type is String
    headers.put("CamelGoogleCalendar.calendarId", calendar.getId());
    // parameter type is com.google.api.services.calendar.model.Calendar
    headers.put("CamelGoogleCalendar.content", calendar.setDescription("foo"));

    Calendar result = requestBodyAndHeaders("direct://UPDATE", null, headers);
    assertTrue("foo".equals(result.getDescription()));

    requestBody("direct://DELETE", calendar.getId());
    try {
        calendarFromGet = requestBody("direct://GET", calendar.getId());
        assertTrue("Should have not found deleted calendar.", false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:CalendarCalendarsIntegrationTest.java


示例6: leaveEvent

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * This method removes the private copy of the Calendar Event
 * 
 * @param event
 * @param zeppaUser
 * @param user
 * @throws GeneralSecurityException
 * @throws IOException
 */
public static boolean leaveEvent(ZeppaEvent event, ZeppaUser zeppaUser) throws IOException {

	boolean success = false;
	com.google.api.services.calendar.Calendar service = GoogleCalendarUtils.makeCalendarServiceInstance();

	Event calEvent = service.events().get(event.getGoogleCalendarId(), event.getGoogleCalendarEventId()).execute();
	Iterator<EventAttendee> iterator = calEvent.getAttendees().iterator();

	while (iterator.hasNext()) {
		EventAttendee attendee = iterator.next();
		if (attendee.getEmail().equals(zeppaUser.getAuthEmail())) {
			success = calEvent.getAttendees().remove(attendee);
			break;
		}
	}

	if (success) {
		service.events().update(event.getGoogleCalendarId(), event.getGoogleCalendarEventId(), calEvent).execute();
	}

	return success;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:32,代码来源:GoogleCalendarService.java


示例7: makeFreeBusyRequest

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Get a list of percentages of users who are free during a given time by
 * time interval
 * 
 * @param startTime
 *            - start time in question
 * @param endTime
 *            - end time in question
 * @param userEmails
 *            - list of emails you desire to retrieve free/busy data for
 * @return ordered list of percentages of users for the given list who are
 *         free
 * @throws IOException 
 */
public static FreeBusyResponse makeFreeBusyRequest(long startTimeMillis, long endTimeMillis,
		List<String> userEmails) throws IOException {

	// Build the calendar service
	com.google.api.services.calendar.Calendar service = GoogleCalendarUtils.makeCalendarServiceInstance();
	
	FreeBusyRequest request = new FreeBusyRequest();
	request.setTimeMin(new DateTime(startTimeMillis));
	request.setTimeMax(new DateTime(endTimeMillis));
	
	// Build request items
	List<FreeBusyRequestItem> requestItems = new ArrayList<FreeBusyRequestItem>();
	for(String email: userEmails){
		FreeBusyRequestItem item = new FreeBusyRequestItem();
		item.setId(email);
		requestItems.add(item);
	}
	request.setItems(requestItems);
	
	return service.freebusy().query(request).execute();
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:36,代码来源:GoogleCalendarService.java


示例8: PreCalendar

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
public PreCalendar(long _guildId, Calendar calendar) {
	guildId = _guildId;
	summary = calendar.getSummary();

	if (calendar.getDescription() != null) {
		description = calendar.getDescription();
	}
	if (calendar.getTimeZone() != null) {
		timezone = calendar.getTimeZone();
	}

	editing = false;

	lastEdit = System.currentTimeMillis();
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:16,代码来源:PreCalendar.java


示例9: calendarTime

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
private void calendarTime(MessageReceivedEvent event, GuildSettings settings) {
	try {
		//TODO: Handle multiple calendars...
		CalendarData data = DatabaseManager.getManager().getMainCalendar(event.getGuild().getLongID());

		if (data.getCalendarAddress().equalsIgnoreCase("primary")) {
			//Does not have a calendar.
			Message.sendMessage(MessageManager.getMessage("Creator.Calendar.NoCalendar", settings), event);
		} else {
			Calendar cal;
			if (settings.useExternalCalendar()) {
				cal = CalendarAuth.getCalendarService(settings).calendars().get(data.getCalendarAddress()).execute();
			} else {
				cal = CalendarAuth.getCalendarService().calendars().get(data.getCalendarAddress()).execute();
			}
			LocalDateTime ldt = LocalDateTime.now(ZoneId.of(cal.getTimeZone()));

			//Okay... format and then we can go from there...
			DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy/MM/dd hh:mm:ss a");
			String thisIsTheCorrectTime = format.format(ldt);

			//Build embed and send.
			EmbedBuilder em = new EmbedBuilder();
			em.withAuthorIcon(Main.client.getGuildByID(266063520112574464L).getIconURL());
			em.withAuthorName("DisCal");
			em.withTitle(MessageManager.getMessage("Embed.Time.Title", settings));
			em.appendField(MessageManager.getMessage("Embed.Time.Time", settings), thisIsTheCorrectTime, false);
			em.appendField(MessageManager.getMessage("Embed.Time.TimeZone", settings), cal.getTimeZone(), false);

			em.withFooterText(MessageManager.getMessage("Embed.Time.Footer", settings));
			em.withUrl(CalendarMessageFormatter.getCalendarLink(cal.getId()));
			em.withColor(56, 138, 237);
			Message.sendMessage(em.build(), event);
		}
	} catch (Exception e) {
		ExceptionHandler.sendException(event.getAuthor(), "Failed to connect to Google Cal.", e, this.getClass());
		Message.sendMessage(MessageManager.getMessage("Notification.Error.Unknown", settings), event);
	}
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:40,代码来源:TimeCommand.java


示例10: convert

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
@Override
public Calendar convert(GoogleCalendar source) {
    Calendar target = new Calendar();
    target.setSummary(source.getName());
    target.setTimeZone(ZoneId.systemDefault().getId());
    return target;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:8,代码来源:GoogleCalendarToCalendarConverter.java


示例11: BeanConverterService

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
private BeanConverterService() {
    converters.put(Pair.of(GoogleEntry.class, Event.class), new GoogleEntryToEventConverter());
    converters.put(Pair.of(Event.class, GoogleEntry.class), new EventToGoogleEntryConverter());
    converters.put(Pair.of(GoogleCalendar.class, CalendarListEntry.class), new GoogleCalendarToCalendarListEntryConverter());
    converters.put(Pair.of(CalendarListEntry.class, GoogleCalendar.class), new CalendarListEntryToGoogleCalendarConverter());
    converters.put(Pair.of(GoogleCalendar.class, Calendar.class), new GoogleCalendarToCalendarConverter());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:8,代码来源:BeanConverterService.java


示例12: getCalendarService

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/***
 * Build and return the authorized Calendar client service
 * @return an authorized Calendar client service
 * @throws IOException
 */
private static com.google.api.services.calendar.Calendar getCalendarService() throws IOException{
	Credential cred = authorize();
	return new com.google.api.services.calendar.Calendar.Builder(
			http, jsonFactory, cred).setApplicationName(Program.APP_NAME)
			.build();
}
 
开发者ID:beesenpai,项目名称:EVE,代码行数:12,代码来源:CalendarAPI.java


示例13: deleteCalendar

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
void deleteCalendar(Calendar cal){
     if(JOptionPane.showConfirmDialog(this, "Delete the calendar?", "EVE Calendars", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
         try {
             Program.calendars.deleteCalendar(cal);
             updateCalendars();
         }
         catch(IOException e){
             JOptionPane.showMessageDialog(this, "Error deleting calendar: " + e.getMessage(), "EVE Calendars", JOptionPane.ERROR_MESSAGE);
         }
     }
}
 
开发者ID:beesenpai,项目名称:EVE,代码行数:12,代码来源:CalendarTab.java


示例14: getCalendarService

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Build and return an authorized Calendar client service.
 * @return an authorized Calendar client service
 * @throws IOException
 */
public static com.google.api.services.calendar.Calendar
    getCalendarService() throws IOException {
    Credential credential = authorize();
    return new com.google.api.services.calendar.Calendar.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName(APPLICATION_NAME)
            .build();
}
 
开发者ID:skimmet,项目名称:magister-google-sync,代码行数:14,代码来源:MagisterGoogleCalendarSyncer.java


示例15: getCalendarService

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Build and return an authorized Calendar client service.
 *
 * @return an authorized Calendar client service
 * @throws IOException
 */
private static com.google.api.services.calendar.Calendar getCalendarService() throws IOException {
    Credential credential = authorize();
    return new com.google.api.services.calendar.Calendar.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, credential)
            .setApplicationName(APPLICATION_NAME)
            .build();
}
 
开发者ID:greenadex,项目名称:timetable-builder,代码行数:14,代码来源:TimetableBuilder.java


示例16: testCalendarList

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
@Test
public void testCalendarList() throws Exception {
    Calendar calendar = getCalendar();
    assertTrue("Test calendar should be in the list", isCalendarInList(calendar));

    CalendarListEntry calendarFromGet = requestBody("direct://GET", calendar.getId());
    assertTrue(calendar.getId().equals(calendarFromGet.getId()));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:CalendarCalendarListIntegrationTest.java


示例17: isCalendarInList

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
protected boolean isCalendarInList(Calendar calendar) {
    CalendarList calendarList = requestBody("direct://LIST", null);

    java.util.List<CalendarListEntry> items = calendarList.getItems();

    boolean found = false;
    for (CalendarListEntry calendarListEntry : items) {
        if (calendar.getSummary().equals(calendarListEntry.getSummary())) {
            found = true;
        }
    }
    return found;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:CalendarCalendarListIntegrationTest.java


示例18: createTestCalendar

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
@Before
public void createTestCalendar() {
    Calendar calendar = new Calendar();
    Random rand = new Random();

    calendar.setSummary("camel-calendar-" + rand.nextInt());
    calendar.setTimeZone("America/St_Johns");

    this.calendar = requestBody("google-calendar://calendars/insert?inBody=content", calendar);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:AbstractGoogleCalendarTestSupport.java


示例19: joinEvent

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * This method adds a copy of the event to the User's Zeppa Calendar
 * 
 * @param zeppaEvent
 *            , ZeppaEvent user is joining
 * @param zeppaUser
 *            , ZeppaUser Object of calling user
 * @param user
 *            , User verification object
 * @throws GeneralSecurityException
 * @throws IOException
 */
public static void joinEvent(ZeppaEvent zeppaEvent, ZeppaUser zeppaUser) throws IOException {

	com.google.api.services.calendar.Calendar service = GoogleCalendarUtils.makeCalendarServiceInstance();

	Event calEvent = service.events().get(zeppaEvent.getGoogleCalendarId(), zeppaEvent.getGoogleCalendarEventId())
			.execute();

	List<EventAttendee> attendees = calEvent.getAttendees();
	EventAttendee attendee = null;
	if (attendees == null) {
		attendees = new ArrayList<EventAttendee>();
	} else {
		Iterator<EventAttendee> iterator = calEvent.getAttendees().iterator();

		while (iterator.hasNext()) {
			EventAttendee temp = iterator.next();
			if (temp.getEmail().equals(zeppaUser.getAuthEmail())) {
				attendee = temp;
				break;
			}
		}

	}
	if (attendee == null) {
		attendee = GoogleCalendarUtils.getUserAsAttendee(zeppaUser);
	}

	attendee.setResponseStatus("accepted");
	attendees.add(attendee);
	calEvent.setAttendees(attendees);

	calEvent = service.events()
			.update(zeppaEvent.getGoogleCalendarId(), zeppaEvent.getGoogleCalendarEventId(), calEvent).execute();

}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:48,代码来源:GoogleCalendarService.java


示例20: deleteCalendar

import com.google.api.services.calendar.model.Calendar; //导入依赖的package包/类
/**
 * Delete the GoogleCalendar for this user
 * 
 * @param zeppaUser
 *            - ZeppaUser who's calendar should be deleted
 * @throws IOException
 */
public static void deleteCalendar(ZeppaUser zeppaUser) throws IOException {

	com.google.api.services.calendar.Calendar service = GoogleCalendarUtils.makeCalendarServiceInstance();

	// Delete all associated rules so calendar removes cleanly
	Acl acl = service.acl().list(zeppaUser.getZeppaCalendarId()).execute();
	if (acl != null && !acl.getItems().isEmpty()) {
		for (AclRule rule : acl.getItems()) {
			service.acl().delete(zeppaUser.getZeppaCalendarId(), rule.getId()).execute();
		}
	}

	service.calendars().delete(zeppaUser.getZeppaCalendarId()).execute();
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:22,代码来源:GoogleCalendarService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ItemEventListener类代码示例发布时间:2022-05-23
下一篇:
Java Tag类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap