开发者

Requirements needed for adding events to Google Calendar?

开发者 https://www.devze.com 2023-01-02 11:29 出处:网络
I need to add events to google calendar form Java without using 开发者_如何学JAVAIDE. What are the requirements are needed to develop my application. Any API is needed to do that? Is it needed how to

I need to add events to google calendar form Java without using 开发者_如何学JAVAIDE. What are the requirements are needed to develop my application. Any API is needed to do that? Is it needed how to use that API in Java. Now I have JDK 1.6 only. Can anyone help me to do this?


You can use Google Data Java Client Library, include the JAR in your projects and use these:

import com.google.gdata.client.*;
import com.google.gdata.client.calendar.*;
import com.google.gdata.data.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.net.URL;

To create a new calendar event, you might use the following code:

URL postUrl =
  new URL("http://www.google.com/calendar/feeds/liz@gmail.com/private/full");
EventEntry myEntry = new EventEntry();

myEntry.setTitle(new PlainTextConstruct("Tennis with Darcy"));
myEntry.setContent(new PlainTextConstruct("Meet for a quick lesson."));

Person author = new Person("Elizabeth Bennet", null, "liz@gmail.com");
myEntry.getAuthors().add(author);

DateTime startTime = DateTime.parseDateTime("2006-04-17T15:00:00-08:00");
DateTime endTime = DateTime.parseDateTime("2006-04-17T17:00:00-08:00");
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);

// Send the request and receive the response:
EventEntry insertedEntry = myService.insert(postUrl, myEntry);

Source: http://code.google.com/apis/gdata/client-java.html

0

精彩评论

暂无评论...
验证码 换一张
取 消