Here you can find the source of toSqlDate(final Date date)
public static java.sql.Date toSqlDate(final Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static java.sql.Date toSqlDate(final int year, final int month, final int dayOfMonth) { return new java.sql.Date(toDate(year, month, dayOfMonth).getTime()); }/* w w w . j ava2 s . c o m*/ public static java.sql.Date toSqlDate(final Date date) { return new java.sql.Date(date.getTime()); } /** * create Date instance. * @param year * @param month Month(start with 1) * @param dayOfMonth * @return */ public static Date toDate(final int year, final int month, final int dayOfMonth) { return toDate(year, month, dayOfMonth, 0, 0, 0); } /** * create Date instance. * @param year * @param month Month(start with 1) * @param dayOfMonth * @param hour * @param minute * @param second * @return */ public static Date toDate(final int year, final int month, final int dayOfMonth, final int hour, final int minute, final int second) { Calendar cal = Calendar.getInstance(); cal.set(year, month - 1, dayOfMonth, hour, minute, second); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } }