diff options
author | Alexander Alexeev | 2016-12-07 18:53:37 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-12-07 22:37:17 +0300 |
commit | bad2718b1b85d806221fce52c76fa1d388993396 (patch) | |
tree | 8788b2b128012c3688fe9d56f295039c8d86f7b3 /juick-rss/src | |
parent | 3f0229dd0c0d07286604c77980ca578c1b3b8cbc (diff) |
singleton java 8 date formatters
Diffstat (limited to 'juick-rss/src')
-rw-r--r-- | juick-rss/src/main/java/com/juick/rss/Main.java | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/juick-rss/src/main/java/com/juick/rss/Main.java b/juick-rss/src/main/java/com/juick/rss/Main.java index adb20a0d..8d247465 100644 --- a/juick-rss/src/main/java/com/juick/rss/Main.java +++ b/juick-rss/src/main/java/com/juick/rss/Main.java @@ -18,8 +18,10 @@ package com.juick.rss; import com.juick.Message; +import com.juick.Tag; import com.juick.server.MessagesQueries; import com.juick.server.UserQueries; +import com.juick.util.DateFormattersHolder; import com.juick.util.MessageUtils; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.lang3.StringEscapeUtils; @@ -33,7 +35,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Properties; @@ -44,7 +45,6 @@ import java.util.Properties; @WebServlet(name = "Main", urlPatterns = {"/"}) public class Main extends HttpServlet { - private static final SimpleDateFormat sdfRSS = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z"); JdbcTemplate sql; @Override @@ -131,19 +131,19 @@ public class Main extends HttpServlet { out.print("<title><![CDATA[@" + msg.getUser().getName() + ":"); if (!msg.getTags().isEmpty()) { - for (int n = 0; n < msg.getTags().size(); n++) { - out.print(" *" + msg.getTags().get(n)); + for (Tag tag : msg.getTags()) { + out.print(" *" + tag); } } out.println("]]></title>"); out.println("<description><![CDATA[" + MessageUtils.formatMessage(msg.getText()) + "]]></description>"); - out.println("<pubDate>" + sdfRSS.format(msg.getDate()) + "</pubDate>"); + out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(msg.getDate()) + "</pubDate>"); out.println("<comments>http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + "</comments>"); if (!msg.getTags().isEmpty()) { - for (int n = 0; n < msg.getTags().size(); n++) { - out.println("<category>" + StringEscapeUtils.escapeHtml4(msg.getTags().get(n).getName()) + "</category>"); + for (Tag tag : msg.getTags()) { + out.println("<category>" + StringEscapeUtils.escapeHtml4(tag.getName()) + "</category>"); } } if (msg.getAttachmentType() != null) { @@ -209,7 +209,7 @@ public class Main extends HttpServlet { out.println("<author>http://juick.com/" + r.uname + "/</author>"); out.println("<title>@" + r.uname + ":</title>"); out.println("<description><![CDATA[" + MessageUtils.formatMessage(r.description) + "]]></description>"); - out.println("<pubDate>" + sdfRSS.format(r.pubDate) + "</pubDate>"); + out.println("<pubDate>" + DateFormattersHolder.getRssFormatterInstance().format(r.pubDate) + "</pubDate>"); String attachment = r.attachmentType; if (attachment != null && !attachment.isEmpty()) { if (attachment.equals("jpg")) { |