Here you can find the source of toSqlDateString(java.sql.Date d, String pattern)
public static String toSqlDateString(java.sql.Date d, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static String toSqlDateString(java.sql.Date d, String pattern) { String rs = ""; try {// ww w. j a v a2s . c om SimpleDateFormat formatter = new SimpleDateFormat(pattern); rs = formatter.format(d); } catch (Exception e) { e.printStackTrace(); } return isFirstStartDate(rs) ? "" : rs; } private static boolean isFirstStartDate(String strDate) { if (strDate.compareTo("1970-01-01") == 0 || strDate.compareTo("1899-12-30") == 0 || strDate.compareTo("1969-12-31") == 0) { return true; } return false; } }