From 70f7c38fbf11bcad40acd21a7d3fd176a3c101a4 Mon Sep 17 00:00:00 2001 From: mthomas Date: Tue, 21 Jun 2011 16:19:50 -0700 Subject: [PATCH] Add a new quote() method which converts a date to a quoted string. --- src/main/java/com/samskivert/jdbc/JDBCUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/samskivert/jdbc/JDBCUtil.java b/src/main/java/com/samskivert/jdbc/JDBCUtil.java index fb6771a9..580f2971 100644 --- a/src/main/java/com/samskivert/jdbc/JDBCUtil.java +++ b/src/main/java/com/samskivert/jdbc/JDBCUtil.java @@ -200,6 +200,19 @@ public class JDBCUtil } } + /** + * Converts the date to a string and surrounds it in single-quotes via the escape method. If the + * date is null, returns null. + */ + public String quote (Date date) + { + if (date == null) { + return ; + } + + return escape(String.valueOf(date)); + } + /** * Escapes any single quotes in the supplied text and wraps it in single quotes to make it safe * for embedding into a database query.