I am trying to use a java.util.Date as input and then creating a query with it - so I need a java.sql.Date.
I was surprised to find that it couldn\'t do the conver
try with this
public static String toMysqlDateStr(Date date) { String dateForMySql = ""; if (date == null) { dateForMySql = null; } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateForMySql = sdf.format(date); } return dateForMySql; }