creating a contact's event in java

39 views
Skip to first unread message

tred

unread,
Apr 22, 2012, 8:12:04 PM4/22/12
to Google Contacts, Shared Contacts and User Profiles APIs
I'm going in circles trying to get an event created for a contact. I
create the contact and send it to google but receive a:

"Bad Request When element does not have start date set or it's
malformed."

Seems to be related to the date of the When in the addEvent().
Documentation says "Only the @startTime attribute is supported.
Furthermore, its value must be a pure date, without the time
component."

Code I'm using is like this:
==============================================

//per documentation: Exactly one of the label and rel attributes must
be provided.
Event event = new Event(null, Event.Rel.ANNIVERSARY) ;

//convert a date string to a date
SimpleDateFormat formatter = new SimpleDateFormat("EEE, d MMM yyyy");
Date date = (Date)f ormatter.parse(pojo.anniversary); // date is a
string formatted like "Mon, 25 Dec 2000 00:00:00 +0000"

When w = new When();
w.setStartTime( new DateTime( date ));
x.setWhen( w );

contact.addEvent(event);

==============================================

What am I missing?

tred

unread,
Apr 22, 2012, 8:37:07 PM4/22/12
to Google Contacts, Shared Contacts and User Profiles APIs
got it..hidden property in the DateTime.

DateTime dateTime = new DateTime(date);
dateTime.setDateOnly(true);
Reply all
Reply to author
Forward
0 new messages