From bad2718b1b85d806221fce52c76fa1d388993396 Mon Sep 17 00:00:00 2001 From: Alexander Alexeev Date: Wed, 7 Dec 2016 18:53:37 +0700 Subject: singleton java 8 date formatters --- juick-rss/src/main/java/com/juick/rss/Main.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'juick-rss/src/main/java') 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("<![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("]]>"); out.println(""); - out.println("" + sdfRSS.format(msg.getDate()) + ""); + out.println("" + DateFormattersHolder.getRssFormatterInstance().format(msg.getDate()) + ""); out.println("http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + ""); if (!msg.getTags().isEmpty()) { - for (int n = 0; n < msg.getTags().size(); n++) { - out.println("" + StringEscapeUtils.escapeHtml4(msg.getTags().get(n).getName()) + ""); + for (Tag tag : msg.getTags()) { + out.println("" + StringEscapeUtils.escapeHtml4(tag.getName()) + ""); } } if (msg.getAttachmentType() != null) { @@ -209,7 +209,7 @@ public class Main extends HttpServlet { out.println("http://juick.com/" + r.uname + "/"); out.println("@" + r.uname + ":"); out.println(""); - out.println("" + sdfRSS.format(r.pubDate) + ""); + out.println("" + DateFormattersHolder.getRssFormatterInstance().format(r.pubDate) + ""); String attachment = r.attachmentType; if (attachment != null && !attachment.isEmpty()) { if (attachment.equals("jpg")) { -- cgit v1.2.3