Here you can find the source of castToSqlDate(Object value)
public static final java.sql.Date castToSqlDate(Object value)
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { public static final java.sql.Date castToSqlDate(Object value) { if (value == null) { return null; }//from w ww. ja v a2s.com if (value instanceof Calendar) { return new java.sql.Date(((Calendar) value).getTimeInMillis()); } if (value instanceof java.sql.Date) { return (java.sql.Date) value; } if (value instanceof java.util.Date) { return new java.sql.Date(((java.util.Date) value).getTime()); } long longValue = 0; if (value instanceof Number) { longValue = ((Number) value).longValue(); } if (value instanceof String) { String strVal = (String) value; if (strVal.length() == 0) { return null; } longValue = Long.parseLong(strVal); } if (longValue <= 0) { throw new IllegalArgumentException("can not cast to Date, value : " + value); } return new java.sql.Date(longValue); } }