From ec6dc4079d2ad28d0ee62b5faf223acaaf48ef59 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 13 Sep 2011 11:31:33 +0200 Subject: Impose format for entry cdate attribute. --- org/madore/damlengine/WeblogPopulate.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'org/madore/damlengine') diff --git a/org/madore/damlengine/WeblogPopulate.java b/org/madore/damlengine/WeblogPopulate.java index c3b76b9..9b6694e 100644 --- a/org/madore/damlengine/WeblogPopulate.java +++ b/org/madore/damlengine/WeblogPopulate.java @@ -53,6 +53,8 @@ public final class WeblogPopulate { = conn.prepareStatement("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1)=(?,DEFAULT,?,?,?::xml,?::xml,?) WHERE id=?"); final PreparedStatement updateCSt = conn.prepareStatement("UPDATE entries SET (edate,mdate,lang,title,title_xml,content,sha1,cdate)=(?,DEFAULT,?,?,?::xml,?::xml,?,?::timestamptz) WHERE id=?"); + final PreparedStatement checkDateSt + = conn.prepareStatement("SELECT to_char(cdate,'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') FROM entries WHERE id=?"); final PreparedStatement clearCatSt = conn.prepareStatement("DELETE FROM incat WHERE id=?"); final PreparedStatement setCatSt @@ -135,6 +137,14 @@ public final class WeblogPopulate { insertSt.setString(8, cdate); insertSt.executeUpdate(); } + if ( ! Pattern.matches("^\\d{4}-\\d{2}-\\d{2}T\\d{2}\\:\\d{2}(?:\\:\\d{2})?(?:Z|[\\+\\-]\\d{2}\\:\\d{2})$", cdate) ) { + checkDateSt.setInt(1, id); + ResultSet checkDate = checkDateSt.executeQuery(); + checkDate.next(); + String checkDateStr = checkDate.getString(1); + System.err.println("cdate for entry "+id+": " + +checkDateStr); + } clearCatSt.setInt(1, id); clearCatSt.executeUpdate(); for ( String cat : catList ) { @@ -152,6 +162,7 @@ public final class WeblogPopulate { insertCSt.close(); updateNSt.close(); updateCSt.close(); + checkDateSt.close(); clearCatSt.close(); setCatSt.close(); -- cgit v1.2.3