Example usage for com.google.gwt.gdata.client DateTime newInstance

List of usage examples for com.google.gwt.gdata.client DateTime newInstance

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client DateTime newInstance.

Prototype

public static native DateTime newInstance(Date date) ;

Source Link

Document

Constructs a timestamp.

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.BloggerQueryBlogPostsDemo.java

License:Apache License

/**
 * Retrieves a posts feed for a blog using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the posts feed, the post entries 
 * are displayed to the user via the showData method.
 * The PublishedMin and PublishedMax parameters are used to
 * limit the range of posts to a given publishing period.
 * // ww w . ja v  a  2 s. c  om
 * @param postsFeedUri The posts feed uri for a given blog.
 */
@SuppressWarnings("deprecation")
private void queryPosts(String postsFeedUri) {
    final BlogPostQuery query = BlogPostQuery.newInstance(postsFeedUri);
    Date minDate = new Date();
    minDate.setMonth(minDate.getMonth() - 1);
    query.setPublishedMin(DateTime.newInstance(minDate));
    query.setPublishedMax(DateTime.newInstance(new Date()));
    showStatus("Querying Blogger for posts...", false);
    service.getBlogPostFeed(query, new BlogPostFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while querying Blogger for Posts: " + caught.getMessage(), true);
        }

        public void onSuccess(BlogPostFeed result) {
            showData(result.getEntries());
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.CalendarCreateEventReminderDemo.java

License:Apache License

/**
 * Create a calendar event by inserting an event entry into
 * a calendar events feed.//  ww  w  . j  a  v a2 s  . co m
 * Set the event's title to an arbitrary string. Here
 * we prefix the title with 'GWT-Calendar-Client' so that
 * we can identify which events were created by this demo.
 * We also specify values for time span and reminder settings.
 * On success and failure, display a status message.
 * 
 * @param eventsFeedUri The uri of the events feed into which to 
 * insert the new event
 */
@SuppressWarnings("deprecation")
private void createEvent(String eventsFeedUri) {
    showStatus("Creating event reminder...", false);
    CalendarEventEntry entry = CalendarEventEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-Calendar-Client: add event reminder");
    When when = When.newInstance();
    Date startTime = new Date();
    Date endTime = new Date();
    endTime.setHours(endTime.getHours() + 1);
    when.setStartTime(DateTime.newInstance(startTime));
    when.setEndTime(DateTime.newInstance(endTime));
    Reminder reminder = Reminder.newInstance();
    reminder.setMinutes(30);
    reminder.setMethod(Reminder.METHOD_ALERT);
    when.addReminder(reminder);
    entry.addTime(when);
    service.insertEntry(eventsFeedUri, entry, new CalendarEventEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus(
                    "An error occurred while creating a Calendar event " + "reminder: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(CalendarEventEntry result) {
            showStatus("Created a Calendar event reminder.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.CalendarCreateEventWithExtendedPropertyDemo.java

License:Apache License

/**
 * Create a calendar event by inserting an event entry into
 * a calendar events feed./*  ww w  . j ava 2s .  c om*/
 * Set the event's title to an arbitrary string. Here
 * we prefix the title with 'GWT-Calendar-Client' so that
 * we can identify which events were created by this demo.
 * We also specify values for time span and an extended
 * property.
 * On success and failure, display a status message.
 * 
 * @param eventsFeedUri The uri of the events feed into which to 
 * insert the new event
 */
@SuppressWarnings("deprecation")
private void createEvent(String eventsFeedUri) {
    showStatus("Creating event reminder...", false);
    CalendarEventEntry entry = CalendarEventEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-Calendar-Client: add extended property");
    When when = When.newInstance();
    Date startTime = new Date();
    Date endTime = new Date();
    endTime.setHours(endTime.getHours() + 1);
    when.setStartTime(DateTime.newInstance(startTime));
    when.setEndTime(DateTime.newInstance(endTime));
    entry.addTime(when);
    CalendarExtendedProperty extendedProp = CalendarExtendedProperty.newInstance();
    extendedProp.setName("mydata");
    extendedProp.setValue("xyz");
    entry.addExtendedProperty(extendedProp);
    service.insertEntry(eventsFeedUri, entry, new CalendarEventEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus(
                    "An error occurred while creating a Calendar event " + "reminder: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(CalendarEventEntry result) {
            showStatus("Created an event with an extended property.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.CalendarCreateSingleEventDemo.java

License:Apache License

/**
 * Create a calendar event by inserting an event entry into
 * a calendar events feed./*w w  w  .j av a  2s. c o m*/
 * Set the event's title to an arbitrary string. Here
 * we prefix the title with 'GWT-Calendar-Client' so that
 * we can identify which events were created by this demo.
 * We also specify values for start and end times.
 * On success and failure, display a status message.
 * 
 * @param eventsFeedUri The uri of the events feed into which to 
 * insert the new event
 */
@SuppressWarnings("deprecation")
private void createEvent(String eventsFeedUri) {
    showStatus("Creating Calendar event...", false);
    CalendarEventEntry eventEntry = CalendarEventEntry.newInstance();
    eventEntry.setTitle(Text.newInstance());
    eventEntry.getTitle().setText("GWT-Calendar-Client: insert event");
    Date startDate = new Date();
    Date endDate = new Date();
    endDate.setHours(endDate.getHours() + 1);
    When when = When.newInstance();
    when.setStartTime(DateTime.newInstance(startDate));
    when.setEndTime(DateTime.newInstance(endDate));
    eventEntry.addTime(when);
    service.insertEntry(eventsFeedUri, eventEntry, new CalendarEventEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a Calendar event: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventEntry result) {
            showStatus("Created a Calendar event taking place in the next hour.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.CalendarQueryEventsByDateDemo.java

License:Apache License

/**
 * Retrieves an events feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the events feed, the event entries 
 * are displayed to the user via the showData method.
 * The MinimumStartTime and MaximumStartTime parameters are used to
 * limit the range of events to a given time period.
 * /* w w  w . ja v a2  s  .co  m*/
 * @param eventsFeedUri The uri of the events feed
 */
@SuppressWarnings("deprecation")
private void queryEvents(String eventsFeedUri) {
    showStatus("Querying for events...", false);
    CalendarEventQuery query = CalendarEventQuery.newInstance(eventsFeedUri);
    Date startDate = new Date();
    startDate.setMonth(startDate.getMonth() - 1);
    Date endDate = new Date();
    query.setMinimumStartTime(DateTime.newInstance(startDate));
    query.setMaximumStartTime(DateTime.newInstance(endDate));
    service.getEventsFeed(query, new CalendarEventFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Event feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventFeed result) {
            CalendarEventEntry[] entries = (CalendarEventEntry[]) result.getEntries();
            if (entries.length == 0) {
                showStatus("No events found for the past month.", false);
            } else {
                showData(entries);
            }
        }
    });
}