Create Calendar Gadget using the Google Data Java client library.

Create Calendar Gadget (WebContent event) using the Google Data Java client library.
  public DateTime getToday() {

  Date today = new Date();

  DateTime datetime = new DateTime(today);

  datetime.setDateOnly(true);

  return datetime;  
}

public DateTime getTomorrow() {

  long oneDay = 24 * 60 * 60 * 1000;

  Date today = new Date();

  DateTime datetime = new DateTime(new Date(today.getTime() + oneDay));

  datetime.setDateOnly(true);

  return datetime;
}

public void createWebContent() throws Exception {
  URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/private/full");

  CalendarEventEntry entry = new CalendarEventEntry();

  entry.setTitle(new PlainTextConstruct("create web content"));
  entry.setContent(new PlainTextConstruct("This event is created by Java client library"));

  DateTime startTime = getToday();
  DateTime endTime = getTomorrow();

  When eventTimes = new When();
  eventTimes.setStartTime(startTime);
  eventTimes.setEndTime(endTime);
  entry.addTime(eventTimes);

  WebContent wc = new WebContent();

  wc.setTitle("title");
  wc.setType("text/html");
  wc.setIcon("http://www.google.com/intl/en_ALL/images/logo.gif");
  wc.setUrl("http://www.google.com");
  wc.setWidth("800");
  wc.setHeight("600");

  entry.setWebContent(wc);

  // Send the request and receive the response:

  calendarService.insert(feedUrl, entry);
  System.out.println("Calendar Gadget is created");
}

6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Dich vu ke toan ACB là thương hiệu lớn tại HCM chuyên cung cấp các dịch vụ kế toán chuyên ngiệp uy tín giá rẻ nhất thị trường. Nhằm tri ân khách hàng, ACB khuyến mãi gói hợp đồng làm dịch vụ kế toán trọn gói lên đến 50%. Để biết thêm chi tiết :dịch vụ kế toán,dich vu ke toan Lầu 4, Tòa Nhà Long Mã, 602 Cộng Hòa, P 13, Q.Tân Bình, HCM Hotline: 0966660888

    ReplyDelete