fixed date
[asciidoctor_to_rss.git] / src / main / java / net / wpitchoune / asciidoctor / Main.java
index 43f0a88..feb103a 100644 (file)
@@ -55,6 +55,8 @@ public class Main {
 
        private static final Asciidoctor asciidoctor = Factory.create();
        
+        private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-dd-MM");        
+       
         private static File toHTMLFile(File dir, File adoc) {
                 int idx;
                 String name;
@@ -113,7 +115,7 @@ public class Main {
         private static void generateHTMLFileItem(File file,
                                                 String title,
                                                 String content,
-                                                String date,
+                                                Date date,
                                                 Configuration cfg) throws IOException {
                StringBuffer buf;
                
@@ -128,7 +130,7 @@ public class Main {
                buf.append("<div id='content'>\n");
                if (date != null) {
                        buf.append("<div class='date'>");
-                       buf.append(date);
+                       buf.append(DATE_FORMATTER.format(date));
                        buf.append("</div>");
                }
                buf.append(content);
@@ -152,9 +154,6 @@ public class Main {
                StringBuffer news;
                String itemTitle, itemContent, itemURI, strDate;
                Date itemDate;
-               SimpleDateFormat sdf;
-               
-               sdf = new SimpleDateFormat("yyyy-dd-MM");
                
                inDir = new File(args[0]);
                outDir = new File(args[1]);
@@ -194,7 +193,7 @@ public class Main {
                        else
                                strDate = h.getAttributes().get("date").toString();
                                                
-                       itemDate = sdf.parse(strDate);
+                       itemDate = DATE_FORMATTER.parse(strDate);
                        
                        asciidoctor.convert(new FileReader(adoc), desc, new HashMap<String,Object>());
                        
@@ -220,13 +219,13 @@ public class Main {
                        news.append("</h2>");
                        if (news != null) {
                                news.append("<div class='date'>");
-                               news.append(itemDate);
+                               news.append(DATE_FORMATTER.format(itemDate));
                                news.append("</div>");
                        }
                        news.append(desc.toString());
                        news.append("</div>\n");     
                        
-                       generateHTMLFileItem(html, itemTitle, itemContent, itemDate.toString(), cfg);
+                       generateHTMLFileItem(html, itemTitle, itemContent, itemDate, cfg);
                }
                
                news.append("</div>\n");