String timestampString = "'"+timestampFormatter.format(t); Timestamp ts = new Timestamp(t.getTime()); String nanoString = ts.getNanos() + ""; nanoString = nanoString.substring(0, 3); timestampString += "." + nanoString + "'";
String timestampString = "'"+timestampFormatter.format(t) + "'";
    public String sqlStringForValue(Object v, String kp) {        String result = super.sqlStringForValue(v,kp);        if(v != null && v != NSKeyValueCoding.NullValue) {            EOAttribute attribute;            int lastDotIdx = kp.lastIndexOf(".");            if (lastDotIdx == -1) {                attribute = entity().attributeNamed(kp);            } else {                EOEntity kpEntity = entityForKeyPath(kp);                attribute = kpEntity.attributeNamed(kp.substring(lastDotIdx+1));            }            if(attribute != null) {                String s = columnTypeStringForAttribute(attribute);                //handel millis seconds, too.                if (v instanceof NSTimestamp) {                    NSTimestamp t = (NSTimestamp)v;                    String timestampString = "'"+timestampFormatter.format(t);                    Timestamp ts = new Timestamp(t.getTime());                    String nanoString = ts.getNanos() + "";                    nanoString = nanoString.substring(0, 3);                    timestampString += "." + nanoString + "'";                    result = timestampString;                }                result = result + "::" + s;            }        }        return result;    }