Here you can find the source of convertToMySqlDate(Date date)
public static java.sql.Date convertToMySqlDate(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static java.sql.Date convertToMySqlDate(Date date) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = dateFormat.format(date); System.out.println(strDate); java.sql.Date sqlDate;//w w w. j av a2 s . co m try { sqlDate = new java.sql.Date(dateFormat.parse(strDate).getTime()); System.out.println(strDate); return sqlDate; } catch (ParseException e) { e.printStackTrace(); return null; } } }