class DBUtils {

    public static void setValueToPreparedStatement(int index, final PreparedStatement preparedStatement, Object value) throws SQLException {

        if (value instanceof Date) {
            preparedStatement.setLong(index, ((Date) value).getTime());

        }else if(value instanceof CharSequence){
            preparedStatement.setString(index, CharSequences.toString((CharSequence)value));

        }else{
            preparedStatement.setObject(index, value);
        }
    }

}