public Date getDate(Calendar calendar) throws SQLException { truncated_ = 0; if (calendar == null) // @dat1 { // getter methods do not enforce strict conversion calendar = Calendar.getInstance(); // @dat1 } return SQLDate.stringToDate(value_, settings_, calendar); }
public void set(Object object, Calendar calendar, int scale) throws SQLException { String value = null; if (object instanceof String) value = (String) object; else if (object instanceof Number) value = object.toString(); else if (object instanceof Boolean) { // @PDC // if "translate boolean" == false, then use "0" and "1" values to match native driver if (settings_.getTranslateBoolean() == true) value = object.toString(); // "true" or "false" else value = ((Boolean) object).booleanValue() == true ? "1" : "0"; } else if (object instanceof Time) value = SQLTime.timeToString((Time) object, settings_, calendar); else if (object instanceof Timestamp) value = SQLTimestamp.timestampToString((Timestamp) object, calendar); else if (object instanceof java.util.Date) value = SQLDate.dateToString((java.util.Date) object, settings_, calendar); else if (object instanceof URL) value = object.toString(); else if (JDUtilities.JDBCLevel_ >= 20 && object instanceof Clob) { Clob clob = (Clob) object; value = clob.getSubString(1, (int) clob.length()); } /* ifdef JDBC40 else if(object instanceof SQLXML) //@PDA jdbc40 { SQLXML xml = (SQLXML)object; value = xml.getString(); } endif */ if (value == null) JDError.throwSQLException(this, JDError.EXC_DATA_TYPE_MISMATCH); value_ = value; originalValue_ = value; // Set to the exact length. int valueLength = value_.length(); int exactLength = getDisplaySize(); if (valueLength < exactLength) { StringBuffer buffer = new StringBuffer(value_); char c = '\u0020'; for (int i = valueLength; i < exactLength; ++i) buffer.append(c); value_ = buffer.toString(); truncated_ = 0; } else if (valueLength > exactLength) { value_ = value_.substring(0, exactLength); truncated_ = valueLength - exactLength; } else truncated_ = 0; }
public void set(Object object, Calendar calendar, int scale) throws SQLException { String value = null; if (object instanceof String) value = (String) object; else if (object instanceof Number) value = object.toString(); else if (object instanceof Boolean) { // if "translate boolean" == false, then use "0" and "1" values to match native driver if (settings_.getTranslateBoolean() == true) value = object.toString(); // "true" or "false" else value = ((Boolean) object).booleanValue() == true ? "1" : "0"; } else if (object instanceof Time) value = SQLTime.timeToString((Time) object, settings_, calendar); else if (object instanceof Timestamp) value = SQLTimestamp.timestampToStringTrimTrailingZeros((Timestamp) object, calendar); else if (object instanceof java.util.Date) value = SQLDate.dateToString((java.util.Date) object, settings_, calendar); else if (JDUtilities.JDBCLevel_ >= 20 && object instanceof Clob) { Clob clob = (Clob) object; value = clob.getSubString(1, (int) clob.length()); } /* ifdef JDBC40 else if(object instanceof SQLXML) { SQLXML xml = (SQLXML)object; value = xml.getString(); } endif */ if (value == null) JDError.throwSQLException(this, JDError.EXC_DATA_TYPE_MISMATCH); value_ = value; // Truncate if necessary. int valueLength = value_.length(); int truncLimit = maxLength_; if (valueLength > truncLimit) { value_ = value_.substring(0, truncLimit); truncated_ = valueLength - truncLimit; } else truncated_ = 0; outOfBounds_ = false; length_ = value_.length(); }