X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fwpitchoune%2Fasciidoctor%2FMain.java;h=feb103a45ce7ce7fe6664df60f199ed7707e054b;hb=1dcb4b2f8e2eeb6b48ff80a02ac1df3dbb31ec21;hp=43f0a88d081928821c1987cbf00b502b47c8a5ac;hpb=fe214ade97ce439e19fc80fcf945f695638f16ed;p=asciidoctor_to_rss.git diff --git a/src/main/java/net/wpitchoune/asciidoctor/Main.java b/src/main/java/net/wpitchoune/asciidoctor/Main.java index 43f0a88..feb103a 100644 --- a/src/main/java/net/wpitchoune/asciidoctor/Main.java +++ b/src/main/java/net/wpitchoune/asciidoctor/Main.java @@ -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("
\n"); if (date != null) { buf.append("
"); - buf.append(date); + buf.append(DATE_FORMATTER.format(date)); buf.append("
"); } 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()); @@ -220,13 +219,13 @@ public class Main { news.append(""); if (news != null) { news.append("
"); - news.append(itemDate); + news.append(DATE_FORMATTER.format(itemDate)); news.append("
"); } news.append(desc.toString()); news.append("
\n"); - generateHTMLFileItem(html, itemTitle, itemContent, itemDate.toString(), cfg); + generateHTMLFileItem(html, itemTitle, itemContent, itemDate, cfg); } news.append("\n");