List of usage examples for org.apache.commons.lang.time DateFormatUtils ISO_DATETIME_TIME_ZONE_FORMAT
FastDateFormat ISO_DATETIME_TIME_ZONE_FORMAT
To view the source code for org.apache.commons.lang.time DateFormatUtils ISO_DATETIME_TIME_ZONE_FORMAT.
Click Source Link
From source file:org.apache.rat.report.claim.impl.xml.SimpleXmlClaimReporter.java
@Override public void startReport() throws RatException { try {/*w w w . j av a 2 s . c o m*/ writer.openElement("rat-report").attribute("timestamp", DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(Calendar.getInstance())); } catch (IOException e) { throw new RatException("Cannot open start element", e); } }
From source file:org.b3log.solo.api.metaweblog.MetaWeblogAPI.java
/** * Builds a post (post struct) with the specified post id. * //www . j av a 2s .c o m * @param postId the specified post id * @return blog info XML * @throws Exception exception */ private String buildPost(final String postId) throws Exception { final StringBuilder stringBuilder = new StringBuilder(); final JSONObject result = articleQueryService.getArticle(postId); if (null == result) { throw new Exception("Not found article[id=" + postId + "]"); } final JSONObject article = result.getJSONObject(Article.ARTICLE); final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE); final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE)); stringBuilder.append("<struct>"); stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>") .append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate)) .append("</dateTime.iso8601></value></member>"); stringBuilder.append("<member><name>description</name>").append("<value>") .append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))) .append("</value></member>"); stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle) .append("</value></member>"); stringBuilder.append("<member><name>categories</name>").append("<value><array><data>"); final JSONArray tags = article.getJSONArray(Article.ARTICLE_TAGS_REF); for (int i = 0; i < tags.length(); i++) { final String tagTitle = tags.getJSONObject(i).getString(Tag.TAG_TITLE); stringBuilder.append("<value>").append(tagTitle).append("</value>"); } stringBuilder.append("</data></array></value></member></struct>"); return stringBuilder.toString(); }
From source file:org.b3log.solo.api.metaweblog.MetaWeblogAPI.java
/** * Builds recent posts (array of post structs) with the specified * fetch size.//w ww. j av a 2s.com * * @param fetchSize the specified fetch size * @return blog info XML * @throws Exception exception */ private String buildRecentPosts(final int fetchSize) throws Exception { final StringBuilder stringBuilder = new StringBuilder(); final List<JSONObject> recentArticles = articleQueryService.getRecentArticles(fetchSize); for (final JSONObject article : recentArticles) { final Date createDate = (Date) article.get(Article.ARTICLE_CREATE_DATE); final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE)); stringBuilder.append("<value><struct>"); stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>") .append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate)) .append("</dateTime.iso8601></value></member>"); stringBuilder.append("<member><name>description</name>").append("<value>") .append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))) .append("</value></member>"); stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle) .append("</value></member>"); stringBuilder.append("<member><name>postid</name>").append("<value>") .append(article.getString(Keys.OBJECT_ID)).append("</value></member>"); stringBuilder.append("<member><name>categories</name>").append("<value><array><data>"); final String tagTitles = article.getString(Article.ARTICLE_TAGS_REF); final String[] tagTitleArray = tagTitles.split(","); for (int i = 0; i < tagTitleArray.length; i++) { final String tagTitle = tagTitleArray[i]; stringBuilder.append("<value>").append(tagTitle).append("</value>"); } stringBuilder.append("</data></array></value></member>"); stringBuilder.append("</struct></value>"); } return stringBuilder.toString(); }
From source file:org.b3log.solo.model.atom.Entry.java
@Override public String toString() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(START_ENTRY_ELEMENT).append(START_TITLE_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(title)); stringBuilder.append(END_TITLE_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_NAME_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(author)); stringBuilder.append(END_NAME_ELEMENT); stringBuilder.append(START_URI_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(uri)); stringBuilder.append(END_URI_ELEMENT); stringBuilder.append(END_AUTHOR_ELEMENT); for (final Category category : categories) { stringBuilder.append(category.toString()); }//w w w. ja v a 2 s. c o m stringBuilder.append(LINK_ELEMENT.replace(LINK_VARIABLE, StringEscapeUtils.escapeXml(link))); stringBuilder.append(START_ID_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(id)); stringBuilder.append(END_ID_ELEMENT); stringBuilder.append(START_UPDATED_ELEMENT); stringBuilder.append(DateFormatUtils.format(// using ISO-8601 instead of RFC-3339 updated, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), TimeZone.getTimeZone(Feed.TIME_ZONE_ID))); stringBuilder.append(END_UPDATED_ELEMENT); stringBuilder.append(START_SUMMARY_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(summary)); stringBuilder.append(END_SUMMARY_ELEMENT); stringBuilder.append(END_ENTRY_ELEMENT); return stringBuilder.toString(); }
From source file:org.b3log.solo.model.atom.Feed.java
@Override public String toString() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(START_DOCUMENT); stringBuilder.append(START_FEED_ELEMENT); stringBuilder.append(START_ID_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(id)); stringBuilder.append(END_ID_ELEMENT); stringBuilder.append(START_TITLE_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(title)); stringBuilder.append(END_TITLE_ELEMENT); stringBuilder.append(START_SUBTITLE_ELEMENT); stringBuilder.append(StringEscapeUtils.escapeXml(subtitle)); stringBuilder.append(END_SUBTITLE_ELEMENT); stringBuilder.append(START_UPDATED_ELEMENT); stringBuilder.append(DateFormatUtils.format(// using ISO-8601 instead of RFC-3339 updated, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), TimeZone.getTimeZone(TIME_ZONE_ID))); stringBuilder.append(END_UPDATED_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_NAME_ELEMENT); stringBuilder.append(author);//w w w . j a v a 2 s .co m stringBuilder.append(END_NAME_ELEMENT); stringBuilder.append(END_AUTHOR_ELEMENT); stringBuilder.append(LINK_ELEMENT.replace(LINK_VARIABLE, StringEscapeUtils.escapeXml(link))); for (final Entry entry : entries) { stringBuilder.append(entry.toString()); } stringBuilder.append(END_FEED_ELEMENT); return XMLs.format(stringBuilder.toString()); }
From source file:org.b3log.solo.model.feed.atom.Entry.java
@Override public String toString() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(START_ENTRY_ELEMENT).append(START_TITLE_ELEMENT); stringBuilder.append(title);// w ww. j a v a 2 s .c o m stringBuilder.append(END_TITLE_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_NAME_ELEMENT); stringBuilder.append(author); stringBuilder.append(END_NAME_ELEMENT); stringBuilder.append(START_URI_ELEMENT); stringBuilder.append(uri); stringBuilder.append(END_URI_ELEMENT); stringBuilder.append(END_AUTHOR_ELEMENT); for (final Category category : categories) { stringBuilder.append(category.toString()); } stringBuilder.append(LINK_ELEMENT.replace(LINK_VARIABLE, link)); stringBuilder.append(START_ID_ELEMENT); stringBuilder.append(id); stringBuilder.append(END_ID_ELEMENT); stringBuilder.append(START_UPDATED_ELEMENT); stringBuilder.append(DateFormatUtils.format(// using ISO-8601 instead of RFC-3339 updated, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), TimeZone.getTimeZone(Feed.TIME_ZONE_ID))); stringBuilder.append(END_UPDATED_ELEMENT); stringBuilder.append(START_SUMMARY_ELEMENT); stringBuilder.append(summary); stringBuilder.append(END_SUMMARY_ELEMENT); stringBuilder.append(END_ENTRY_ELEMENT); return stringBuilder.toString(); }
From source file:org.b3log.solo.model.feed.atom.Feed.java
@Override public String toString() { final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(START_DOCUMENT); stringBuilder.append(START_FEED_ELEMENT); stringBuilder.append(START_ID_ELEMENT); stringBuilder.append(id);// ww w . j a v a 2 s . co m stringBuilder.append(END_ID_ELEMENT); stringBuilder.append(START_TITLE_ELEMENT); stringBuilder.append(title); stringBuilder.append(END_TITLE_ELEMENT); stringBuilder.append(START_SUBTITLE_ELEMENT); stringBuilder.append(subtitle); stringBuilder.append(END_SUBTITLE_ELEMENT); stringBuilder.append(START_UPDATED_ELEMENT); stringBuilder.append(DateFormatUtils.format(// using ISO-8601 instead of RFC-3339 updated, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern(), TimeZone.getTimeZone(TIME_ZONE_ID))); stringBuilder.append(END_UPDATED_ELEMENT); stringBuilder.append(START_AUTHOR_ELEMENT); stringBuilder.append(START_NAME_ELEMENT); stringBuilder.append(author); stringBuilder.append(END_NAME_ELEMENT); stringBuilder.append(END_AUTHOR_ELEMENT); stringBuilder.append(LINK_ELEMENT.replace(LINK_VARIABLE, link)); for (final Entry entry : entries) { stringBuilder.append(entry.toString()); } stringBuilder.append(END_FEED_ELEMENT); return stringBuilder.toString(); }
From source file:org.b3log.solo.processor.api.MetaWeblogAPI.java
/** * Builds a post (post struct) with the specified post id. * * @param postId the specified post id/*from w ww.ja va 2 s . c om*/ * @return blog info XML * @throws Exception exception */ private String buildPost(final String postId) throws Exception { final StringBuilder stringBuilder = new StringBuilder(); final JSONObject result = articleQueryService.getArticle(postId); if (null == result) { throw new Exception("Not found article[id=" + postId + "]"); } final JSONObject article = result.getJSONObject(Article.ARTICLE); final long createDate = article.getLong(Article.ARTICLE_CREATED); final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE)); stringBuilder.append("<struct>"); stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>") .append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate)) .append("</dateTime.iso8601></value></member>"); stringBuilder.append("<member><name>description</name>").append("<value>") .append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))) .append("</value></member>"); stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle) .append("</value></member>"); stringBuilder.append("<member><name>categories</name>").append("<value><array><data>"); final JSONArray tags = article.getJSONArray(Article.ARTICLE_TAGS_REF); for (int i = 0; i < tags.length(); i++) { final String tagTitle = tags.getJSONObject(i).getString(Tag.TAG_TITLE); stringBuilder.append("<value>").append(tagTitle).append("</value>"); } stringBuilder.append("</data></array></value></member></struct>"); return stringBuilder.toString(); }
From source file:org.b3log.solo.processor.api.MetaWeblogAPI.java
/** * Builds recent posts (array of post structs) with the specified fetch size. * * @param fetchSize the specified fetch size * @return blog info XML// w w w. j a v a 2s . c om * @throws Exception exception */ private String buildRecentPosts(final int fetchSize) throws Exception { final StringBuilder stringBuilder = new StringBuilder(); final List<JSONObject> recentArticles = articleQueryService.getRecentArticles(fetchSize); for (final JSONObject article : recentArticles) { final long createDate = article.getLong(Article.ARTICLE_CREATED); final String articleTitle = StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_TITLE)); stringBuilder.append("<value><struct>"); stringBuilder.append("<member><name>dateCreated</name>").append("<value><dateTime.iso8601>") .append(DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(createDate)) .append("</dateTime.iso8601></value></member>"); stringBuilder.append("<member><name>description</name>").append("<value>") .append(StringEscapeUtils.escapeXml(article.getString(Article.ARTICLE_CONTENT))) .append("</value></member>"); stringBuilder.append("<member><name>title</name>").append("<value>").append(articleTitle) .append("</value></member>"); stringBuilder.append("<member><name>postid</name>").append("<value>") .append(article.getString(Keys.OBJECT_ID)).append("</value></member>"); stringBuilder.append("<member><name>categories</name>").append("<value><array><data>"); final String tagTitles = article.getString(Article.ARTICLE_TAGS_REF); final String[] tagTitleArray = tagTitles.split(","); for (int i = 0; i < tagTitleArray.length; i++) { final String tagTitle = tagTitleArray[i]; stringBuilder.append("<value>").append(tagTitle).append("</value>"); } stringBuilder.append("</data></array></value></member>"); stringBuilder.append("</struct></value>"); } return stringBuilder.toString(); }
From source file:org.b3log.solo.processor.SitemapProcessor.java
/** * Adds articles into the specified sitemap. * /* w w w. j a v a 2 s. c o m*/ * @param sitemap the specified sitemap * @param preference the specified preference * @throws Exception exception */ private void addArticles(final Sitemap sitemap, final JSONObject preference) throws Exception { final String host = preference.getString(Preference.BLOG_HOST); // XXX: query all articles? final Query query = new Query().setCurrentPageNum(1) .setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)) .addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING); // Closes cache avoid Java heap space out of memory while caching query results articleRepository.setCacheEnabled(false); final JSONObject articleResult = articleRepository.get(query); articleRepository.setCacheEnabled(true); // Restores cache final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS); for (int i = 0; i < articles.length(); i++) { final JSONObject article = articles.getJSONObject(i); final String permalink = article.getString(Article.ARTICLE_PERMALINK); final URL url = new URL(); url.setLoc("http://" + host + permalink); final Date updateDate = (Date) article.get(Article.ARTICLE_UPDATE_DATE); final String lastMod = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(updateDate); url.setLastMod(lastMod); sitemap.addURL(url); } }