views:

31

answers:

1

Hi all. I need to add events to google calendar form Java without using IDE. 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?

+3  A: 

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/[email protected]/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, "[email protected]");
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

Bakkal
Thanks for your response
Sumithran