Example usage for org.joda.time DateTime toString

List of usage examples for org.joda.time DateTime toString

Introduction

In this page you can find the example usage for org.joda.time DateTime toString.

Prototype

@ToString
public String toString() 

Source Link

Document

Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ).

Usage

From source file:com.melexis.esb.eventstore.impl.EventDaoCassandraImpl.java

License:Apache License

public List<Event> findEvents(String source, DateTime start, DateTime end, int max) {

    String from = (start == null) ? "" : start.toString();
    String till = (end == null) ? "" : end.toString();

    IndexedSlicesQuery<String, String, String> query = createIndexedSlicesQuery(keyspace, SERIALIZER,
            SERIALIZER, SERIALIZER);/*from  w  w  w . j  ava 2  s.c o m*/
    query.setColumnFamily(columnFamily);

    query.addEqualsExpression(SOURCE, source);

    addDateTimeConstraints(start, end, from, till, query);

    query.setRange("A", "z", false, 1000);

    List<Row<String, String, String>> rows = query.execute().get().getList();

    final List<Event> results = Lists.transform(rows, ROW_TO_EVENT_FN);

    return orderedResultSet(from, till, results, max);
}

From source file:com.melexis.esb.eventstore.impl.EventDaoCassandraImpl.java

License:Apache License

@Override
public List<Event> findEventsForLotnameAndSource(final String lotname, final String source,
        @Nullable DateTime start, @Nullable DateTime end, int max) {
    String from = (start == null) ? "" : start.toString();
    String till = (end == null) ? "" : end.toString();

    IndexedSlicesQuery<String, String, String> query = createIndexedSlicesQuery(keyspace, SERIALIZER,
            SERIALIZER, SERIALIZER);/*from  w w w  .j  a v  a  2  s.  c o  m*/

    query.setColumnFamily(columnFamily);

    query.addEqualsExpression(LOTNAME, lotname);
    query.addEqualsExpression(SOURCE, source);
    query.setRange("A", "z", false, 1000);
    query.setStartKey("");

    addDateTimeConstraints(start, end, from, till, query);

    final List<Row<String, String, String>> rows = query.execute().get().getList();
    final List<Event> results = Lists.transform(rows, ROW_TO_EVENT_FN);

    return orderedResultSet(from, till, results, max);
}

From source file:com.melexis.esb.eventstore.impl.EventDaoCassandraImpl.java

License:Apache License

@Override
public List<Event> findEventsForProcessIdAndSource(final String processId, final String source,
        @Nullable DateTime start, @Nullable DateTime end, int max) {
    String from = (start == null) ? "" : start.toString();
    String till = (end == null) ? "" : end.toString();

    IndexedSlicesQuery<String, String, String> query = createIndexedSlicesQuery(keyspace, SERIALIZER,
            SERIALIZER, SERIALIZER);//from  w w  w .  j ava  2 s. co m
    query.setColumnFamily(columnFamily);

    query.addEqualsExpression(PROCESSID, processId);
    query.addEqualsExpression(SOURCE, source);
    query.setRange("A", "z", false, 1000);
    query.setStartKey("");

    addDateTimeConstraints(start, end, from, till, query);

    final List<Row<String, String, String>> rows = query.execute().get().getList();
    final List<Event> results = Lists.transform(rows, ROW_TO_EVENT_FN);

    return orderedResultSet(from, till, results, max);
}

From source file:com.microsoft.o365_android_onenote_rest.snippet.PagesSnippet.java

License:MIT License

static PagesSnippet[] getPagesSnippets() {
    return new PagesSnippet[] {
            // Marker element
            new PagesSnippet(null) {
                @Override//w ww  . j av  a 2s  .c  o  m
                public void request(PagesService service, Callback callback) {
                    // Not implemented
                }
            },

            /*
             * POST a new OneNote page in the section picked by the user
             * HTTP POST https://graph.microsoft.com/v1.0/me/onenote/sections/{id}/pages
             * @see http://dev.onenote.com/docs#/reference/post-pages
             */
            new PagesSnippet<Page>(create_simple_page, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();
                String endpointVersion;

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Page> callback) {
                    DateTime date = DateTime.now();

                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.simple_page),
                            date.toString(), null);
                    String contentType = "text/html; encoding=utf8";

                    TypedString typedString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postPages(contentType, //Content-Type value
                            getVersion(), //Version
                            section.id, //Section Id,
                            typedString, //HTML note body,
                            callback);
                }
            },

            /*
             * Creates a new page in a section referenced by title instead of Id
             * HTTP POST https://graph.microsoft.com/v1.0/me/onenote/pages{?sectionName}
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespagessectionname
             */
            new PagesSnippet<Envelope<Page>>(create_page_under_named_section, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();
                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.simple_page),
                            date.toString(), null);

                    TypedString typedString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postPagesInSection("text/html; encoding=utf8", getVersion(), section.displayName,
                            typedString, callback);
                }
            },

            /*
             * Creates a page with an embedded image
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_image, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();

                    String imagePartName = "image1";
                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.create_page_with_image),
                            date.toString(), imagePartName);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);

                    File imageFile = getImageFile("/res/drawable/logo.jpg");
                    TypedFile typedFile = new TypedFile("image/jpg", imageFile);
                    oneNotePartsMap.put(imagePartName, typedFile);
                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Gets a page by using a filter query that asks for
             * pages whose title contains text input by user
             */
            new PagesSnippet(specific_title, Input.Text) {
                @Override
                public void request(PagesService service, Callback callback) {

                    service.getPages(
                            getVersion(), "contains(title,'"
                                    + callback.getParams().get(SnippetDetailFragment.ARG_TEXT_INPUT) + "')",
                            null, null, null, null, null, callback);
                }
            },

            /*
             * Creates a new page with an embedded web page
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_web_page_snapshot, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();
                    String embeddedPartName = "part1";
                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.create_page_with_web_snap),
                            date.toString(), embeddedPartName);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };

                    String embeddedWebPage = "";
                    try {
                        embeddedWebPage = IOUtils.toString(SnippetApp.getApp().getResources()
                                .openRawResource(R.raw.create_page_with_web_snap_part1));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                    TypedString typedStringPart2 = new TypedString(embeddedWebPage) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };

                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);
                    oneNotePartsMap.put(embeddedPartName, typedStringPart2);

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Deletes a page specified by page Id
             * @see http://dev.onenote.com/docs#/reference/delete-pages
             */
            new PagesSnippet<Envelope<Page>>(delete_page, Input.Spinner) {

                Map<String, Page> pageMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillPageSpinner(services, callback, pageMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    Page page = pageMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.deletePage(getVersion(), page.id, callback);
                }
            },

            /*
             * Appends an HTML para to the end of the page selected by the user
             * @see http://dev.onenote.com/docs#/reference/patch-pages
             */
            new PagesSnippet<Envelope<Page>>(page_append, Input.Spinner) {

                Map<String, Page> pageMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillPageSpinner(services, callback, pageMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    //Create PatchCommand list and convert to json to build patch request body
                    PatchCommand command = new PatchCommand();
                    command.mAction = "append";
                    command.mTarget = "body";
                    command.mPosition = "after";
                    command.mContent = "<p>New trailing content</p>";
                    JsonArray jsonArray = new JsonArray();
                    jsonArray.add(command.serialize(command, null, null));
                    Timber.d(jsonArray.toString());
                    TypedString typedString = new TypedString(jsonArray.toString()) {
                        @Override
                        public String mimeType() {
                            return "application/json";
                        }
                    };

                    Page page = pageMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.patchPage("", getVersion(), page.id, typedString, callback);
                }
            },

            /*
             * Creates a page that embeds a webpage and renders the embedded web page
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_url_snapshot, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();
                    String simpleHtml = getSimplePageContentBody(SnippetApp.getApp().getResources()
                            .openRawResource(R.raw.create_page_with_url_snapshot), date.toString(), null);

                    TypedString typedString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };

                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(typedString);

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Gets a collection of pages in a specific section
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(pages_specific_section, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.getSectionPages(getVersion(), section.id, null, null, null, null, null, callback);
                }
            },

            /*
             * Creates a page that embeds an image
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_pdf, Input.Spinner) {

                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();
                    String pdfPartName = "pdfattachment1";
                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.create_page_with_pdf),
                            date.toString(), pdfPartName);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);

                    File imageFile = getImageFile("/res/raw-en/attachment.pdf");

                    TypedFile typedFile = new TypedFile("application/pdf", imageFile);
                    oneNotePartsMap.put(pdfPartName, typedFile);

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Creates a new page with HTML content that includes para tags with data-tag attributes
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_note_tags, Input.Spinner) {
                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    DateTime date = DateTime.now();
                    String simpleHtml = getSimplePageContentBody(SnippetApp.getApp().getResources()
                            .openRawResource(R.raw.create_page_with_note_tags), date.toString(), null);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Creates a new page with content extracted from an image
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_business_cards, Input.Spinner) {
                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    DateTime date = DateTime.now();
                    String imagePartName = "image1";
                    String simpleHtml = getSimplePageContentBody(SnippetApp.getApp().getResources()
                            .openRawResource(R.raw.create_page_with_business_cards), date.toString(),
                            imagePartName);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);
                    File imageFile = getImageFile("/res/drawable/bizcard.png");

                    TypedFile typedFile = new TypedFile("image/jpg", imageFile);
                    oneNotePartsMap.put(imagePartName, typedFile);
                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Create a new page with contents that are extracted from a web page
             * specified by Url in the HTML from the raw resource
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_recipe, Input.Spinner) {
                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    DateTime date = DateTime.now();
                    String simpleHtml = getSimplePageContentBody(
                            SnippetApp.getApp().getResources().openRawResource(R.raw.create_page_with_recipe),
                            date.toString(), null);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);
                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Creates a new page with the content of a web page referenced by Url in
             * HTML from raw resource
             * @see http://dev.onenote.com/docs#/reference/post-pages/v10menotespages
             */
            new PagesSnippet<Envelope<Page>>(create_page_with_product_info, Input.Spinner) {
                Map<String, Section> sectionMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillSectionSpinner(services, callback, sectionMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    DateTime date = DateTime.now();
                    String simpleHtml = getSimplePageContentBody(SnippetApp.getApp().getResources()
                            .openRawResource(R.raw.create_page_with_product_info), date.toString(), null);

                    TypedString presentationString = new TypedString(simpleHtml) {
                        @Override
                        public String mimeType() {
                            return "text/html";
                        }
                    };
                    OneNotePartsMap oneNotePartsMap = new OneNotePartsMap(presentationString);

                    Section section = sectionMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.postMultiPartPages(getVersion(), section.id, oneNotePartsMap, callback);
                }
            },

            /*
             * Get a collection of all the user's pages
             * @see http://dev.onenote.com/docs#/reference/get-pages/v10menotespagesfilterorderbyselecttopskipsearchcount
             */
            new PagesSnippet<Envelope<Page>>(get_all_pages) {
                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    service.getPages(getVersion(), null, null, null, //select
                            null, null, null, callback);
                }
            },

            /*
             * Get a 20 page collection, starting with the 3rd page in the user's collection
             * @see http://dev.onenote.com/docs#/reference/get-pages/v10menotessectionsidpagesfilterorderbyselecttopskipsearchcount
             */
            new PagesSnippet<Envelope<Page>>(get_pages_skip_and_top) {
                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    service.getPages(getVersion(), null, null, null, 20, 3, null, callback);
                }
            },

            /*
             * GET a page from the user's page collection for specific id
             */
            new PagesSnippet<Envelope<Page>>(meta_specific_page, Input.Spinner) {

                Map<String, Page> pageMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillPageSpinner(services, callback, pageMap);
                }

                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {

                    Page page = pageMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.getPageById(getVersion(), page.id, callback);
                }
            },

            /*
             * GET a collection of pages ordered by title
             */
            new PagesSnippet<Envelope<Page>>(pages_selected_meta) {
                @Override
                public void request(PagesService service, Callback<Envelope<Page>> callback) {
                    service.getPages(getVersion(), null, "title", "id,title", null, null, null, callback);

                }
            },

            /*
             * GET the content of a page specified by page id
             */
            new PagesSnippet<Response>(get_page_as_html, Input.Spinner) {
                Map<String, Page> pageMap = new HashMap<>();

                @Override
                public void setUp(Services services, final retrofit.Callback<String[]> callback) {
                    fillPageSpinner(services, callback, pageMap);
                }

                @Override
                public void request(PagesService service, Callback<Response> callback) {
                    Page page = pageMap
                            .get(callback.getParams().get(SnippetDetailFragment.ARG_SPINNER_SELECTION));

                    service.getPageContentById(getVersion(), page.id, "text/html", callback);
                }
            } };
}

From source file:com.microsoft.onenoteapi.service.DateTimeSerializer.java

License:MIT License

public JsonElement serialize(DateTime src, Type typeOfSrc, JsonSerializationContext context) {
    return new JsonPrimitive(src.toString());
}

From source file:com.monarchapis.client.resource.AbstractResource.java

License:Open Source License

protected String convert(DateTime dateTime) {
    return dateTime != null ? dateTime.toString() : null;
}

From source file:com.monarchapis.client.rest.BaseClient.java

License:Open Source License

public T setPath(String name, DateTime dateTime) {
    return setPath(name, (String) (dateTime != null ? dateTime.toString() : null));
}

From source file:com.monarchapis.client.rest.BaseClient.java

License:Open Source License

public T addParameter(String name, DateTime dateTime) {
    return addParameter(name, (String) (dateTime != null ? dateTime.toString() : null));
}

From source file:com.monarchapis.client.rest.BaseClient.java

License:Open Source License

public T setParameter(String name, DateTime dateTime) {
    return setParameter(name, (String) (dateTime != null ? dateTime.toString() : null));
}

From source file:com.monarchapis.client.rest.BaseClient.java

License:Open Source License

public T addQuery(String name, DateTime dateTime) {
    return addQuery(name, (String) (dateTime != null ? dateTime.toString() : null));
}