| java.lang.Object org.apache.derby.iapi.types.DataType org.apache.derby.iapi.types.SQLDate
SQLDate | final public class SQLDate extends DataType implements DateTimeDataValue(Code) | | This contains an instance of a SQL Date.
The date is stored as int (year << 16 + month << 8 + day)
Null is represented by an encodedDate value of 0.
Some of the static methods in this class are also used by SQLTime and SQLTimestamp
so check those classes if you change the date encoding
PERFORMANCE OPTIMIZATION:
The java.sql.Date object is only instantiated when needed
do to the overhead of Date.valueOf(), etc. methods.
|
Method Summary | |
public int | compare(DataValueDescriptor other) | public boolean | compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) | public static DateTimeDataValue | computeDateFunction(DataValueDescriptor operand, DataValueFactory dvf) Implement the date SQL function: construct a SQL date from a string, number, or timestamp. | static int | computeEncodedDate(Calendar cal) | static int | computeEncodedDate(int y, int m, int d) | static int | computeEncodedDate(java.util.Date value, Calendar currentCal) | static void | dateToString(int year, int month, int day, StringBuffer sb) Convert a date to the JDBC representation and append it to a string buffer. | static String | encodedDateToString(int encodedDate) Get the String version from the encodedDate. | public int | estimateMemoryUsage() | public DataValueDescriptor | getClone() | public NumberDataValue | getDate(NumberDataValue result) | public Date | getDate(Calendar cal) Get the value field. | static int | getDay(int encodedDate) Get the day from the encodedDate. | int | getEncodedDate() | public NumberDataValue | getHours(NumberDataValue result) | public int | getLength() | public NumberDataValue | getMinutes(NumberDataValue result) | public NumberDataValue | getMonth(NumberDataValue result) | static int | getMonth(int encodedDate) Get the month from the encodedDate. | protected String | getNationalString(LocaleFinder localeFinder) International version of getString(). | public DataValueDescriptor | getNewNull() | public Object | getObject() | public NumberDataValue | getSeconds(NumberDataValue result) | public String | getString() | public Timestamp | getTimestamp(Calendar cal) | public int | getTypeFormatId() Return my format identifier. | public String | getTypeName() | public NumberDataValue | getYear(NumberDataValue result) | static int | getYear(int encodedDate) Get the year from the encodedDate. | public int | hashCode() | final public boolean | isNull() Check if the value is null. | public void | readExternal(ObjectInput in) | public void | readExternalFromArray(ArrayInputStream in) | public void | restoreToNull() | protected void | setFrom(DataValueDescriptor theValue) | public void | setInto(PreparedStatement ps, int position) Adding this method to ensure that super class' setInto method doesn't get called
that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on. | void | setObject(Object theValue) Set the value from a correctly typed Date object. | static NumberDataValue | setSource(int value, NumberDataValue source) This helper routine tests the nullability of various parameters
and sets up the result appropriately.
If source is null, a new NumberDataValue is built. | public void | setValue(Date value, Calendar cal) | public void | setValue(Timestamp value, Calendar cal) | public void | setValue(String theValue) | public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) | public DateTimeDataValue | timestampAdd(int intervalType, NumberDataValue intervalCount, java.sql.Date currentDate, DateTimeDataValue resultHolder) Add a number of intervals to a datetime value. | public NumberDataValue | timestampDiff(int intervalType, DateTimeDataValue time1, java.sql.Date currentDate, NumberDataValue resultHolder) Finds the difference between two datetime values as a number of intervals. | public String | toString() | public int | typePrecedence() | public void | writeExternal(ObjectOutput out) |
ISO_SEPARATOR | final static char ISO_SEPARATOR(Code) | | |
SQLDate | public SQLDate()(Code) | | no-arg constructor required by Formattable
|
SQLDate | public SQLDate(String dateStr, boolean isJdbcEscape, LocaleFinder localeFinder) throws StandardException(Code) | | Construct a date from a string. The allowed date formats are:
- ISO: yyyy-mm-dd
- IBM USA standard: mm/dd/yyyy
- IBM European standard: dd.mm.yyyy
Trailing blanks may be included; leading zeros may be omitted from the month and day portions.
Parameters: dateStr - Parameters: isJdbcEscape - if true then only the JDBC date escape syntax is allowed Parameters: localeFinder - exception: Standard - exception if the syntax is invalid or the value is out of range. |
SQLDate | public SQLDate(String dateStr, boolean isJdbcEscape, LocaleFinder localeFinder, Calendar cal) throws StandardException(Code) | | Construct a date from a string. The allowed date formats are:
- ISO: yyyy-mm-dd
- IBM USA standard: mm/dd/yyyy
- IBM European standard: dd.mm.yyyy
Trailing blanks may be included; leading zeros may be omitted from the month and day portions.
Parameters: dateStr - Parameters: isJdbcEscape - if true then only the JDBC date escape syntax is allowed Parameters: localeFinder - exception: Standard - exception if the syntax is invalid or the value is out of range. |
computeEncodedDate | static int computeEncodedDate(Calendar cal) throws StandardException(Code) | | computeEncodedDate extracts the year, month and date from
a Calendar value and encodes them as
year << 16 + month << 8 + date
Use this function will help to remember to add 1 to month
which is 0 based in the Calendar class
Parameters: cal - the Calendar the encodedDate exception: StandardException - if the value is out of the DB2 date range |
dateToString | static void dateToString(int year, int month, int day, StringBuffer sb)(Code) | | Convert a date to the JDBC representation and append it to a string buffer.
Parameters: year - Parameters: month - 1 based (January == 1) Parameters: day - Parameters: sb - The string representation is appended to this StringBuffer |
encodedDateToString | static String encodedDateToString(int encodedDate)(Code) | | Get the String version from the encodedDate.
string value. |
estimateMemoryUsage | public int estimateMemoryUsage()(Code) | | |
getDate | public Date getDate(Calendar cal)(Code) | | Get the value field. We instantiate the field
on demand.
The value field. |
getDay | static int getDay(int encodedDate)(Code) | | Get the day from the encodedDate.
Parameters: encodedDate - the encoded date day value. |
getEncodedDate | int getEncodedDate()(Code) | | |
getLength | public int getLength()(Code) | | |
getMonth | static int getMonth(int encodedDate)(Code) | | Get the month from the encodedDate.
Parameters: encodedDate - the encoded date month value. |
getObject | public Object getObject()(Code) | | getObject returns the date value
|
getTimestamp | public Timestamp getTimestamp(Calendar cal)(Code) | | getTimestamp returns a timestamp with the date value
time is set to 00:00:00.0
|
getYear | static int getYear(int encodedDate)(Code) | | Get the year from the encodedDate.
Parameters: encodedDate - the encoded date year value. |
hashCode | public int hashCode()(Code) | | |
isNull | final public boolean isNull()(Code) | | Check if the value is null.
encodedDate is 0 if the value is null
Whether or not value is logically null. |
setInto | public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code) | | Adding this method to ensure that super class' setInto method doesn't get called
that leads to the violation of JDBC spec( untyped nulls ) when batching is turned on.
|
timestampAdd | public DateTimeDataValue timestampAdd(int intervalType, NumberDataValue intervalCount, java.sql.Date currentDate, DateTimeDataValue resultHolder) throws StandardException(Code) | | Add a number of intervals to a datetime value. Implements the JDBC escape TIMESTAMPADD function.
Parameters: intervalType - One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL Parameters: intervalCount - The number of intervals to add Parameters: currentDate - Used to convert time to timestamp Parameters: resultHolder - If non-null a DateTimeDataValue that can be used to hold the result. If null thengenerate a new holder startTime + intervalCount intervals, as a timestamp exception: StandardException - |
timestampDiff | public NumberDataValue timestampDiff(int intervalType, DateTimeDataValue time1, java.sql.Date currentDate, NumberDataValue resultHolder) throws StandardException(Code) | | Finds the difference between two datetime values as a number of intervals. Implements the JDBC
TIMESTAMPDIFF escape function.
Parameters: intervalType - One of FRAC_SECOND_INTERVAL, SECOND_INTERVAL, MINUTE_INTERVAL, HOUR_INTERVAL,DAY_INTERVAL, WEEK_INTERVAL, MONTH_INTERVAL, QUARTER_INTERVAL, or YEAR_INTERVAL Parameters: time1 - Parameters: currentDate - Used to convert time to timestamp Parameters: resultHolder - If non-null a NumberDataValue that can be used to hold the result. If null thengenerate a new holder the number of intervals by which this datetime is greater than time1 exception: StandardException - |
Methods inherited from org.apache.derby.iapi.types.DataType | public void checkHostVariable(int declaredLength) throws StandardException(Code)(Java Doc) public Object cloneObject()(Code)(Java Doc) public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException(Code)(Java Doc) public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code)(Java Doc) final protected StandardException dataTypeConversion(String targetType)(Code)(Java Doc) public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public boolean equals(Object other)(Code)(Java Doc) protected static int flip(int operator)(Code)(Java Doc) void genericSetObject(Object theValue) throws StandardException(Code)(Java Doc) public boolean getBoolean() throws StandardException(Code)(Java Doc) public byte getByte() throws StandardException(Code)(Java Doc) public byte[] getBytes() throws StandardException(Code)(Java Doc) public Date getDate(Calendar cal) throws StandardException(Code)(Java Doc) public double getDouble() throws StandardException(Code)(Java Doc) public float getFloat() throws StandardException(Code)(Java Doc) public int getInt() throws StandardException(Code)(Java Doc) public long getLong() throws StandardException(Code)(Java Doc) protected String getNationalString(LocaleFinder localeFinder) throws StandardException(Code)(Java Doc) public Object getObject() throws StandardException(Code)(Java Doc) public short getShort() throws StandardException(Code)(Java Doc) public InputStream getStream() throws StandardException(Code)(Java Doc) public Time getTime(Calendar cal) throws StandardException(Code)(Java Doc) public Timestamp getTimestamp(Calendar cal) throws StandardException(Code)(Java Doc) public String getTraceString() throws StandardException(Code)(Java Doc) String getTypeName(String className)(Code)(Java Doc) public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException(Code)(Java Doc) final protected StandardException invalidFormat()(Code)(Java Doc) final public BooleanDataValue isNotNull()(Code)(Java Doc) final public BooleanDataValue isNullOp()(Code)(Java Doc) public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException(Code)(Java Doc) public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code)(Java Doc) final protected StandardException outOfRange()(Code)(Java Doc) public void setBigDecimal(Number bigDecimal) throws StandardException(Code)(Java Doc) protected void setFrom(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException(Code)(Java Doc) public void setInto(ResultSet rs, int position) throws SQLException, StandardException(Code)(Java Doc) void setObject(Object theValue) throws StandardException(Code)(Java Doc) public void setObjectForCast(Object theValue, boolean instanceOfResultType, String resultTypeClassName) throws StandardException(Code)(Java Doc) public void setToNull()(Code)(Java Doc) public void setValue(Time theValue) throws StandardException(Code)(Java Doc) public void setValue(Time theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue) throws StandardException(Code)(Java Doc) public void setValue(Timestamp theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(Date theValue) throws StandardException(Code)(Java Doc) public void setValue(Date theValue, Calendar cal) throws StandardException(Code)(Java Doc) public void setValue(String theValue) throws StandardException(Code)(Java Doc) public void setValue(int theValue) throws StandardException(Code)(Java Doc) public void setValue(double theValue) throws StandardException(Code)(Java Doc) public void setValue(float theValue) throws StandardException(Code)(Java Doc) public void setValue(short theValue) throws StandardException(Code)(Java Doc) public void setValue(long theValue) throws StandardException(Code)(Java Doc) public void setValue(byte theValue) throws StandardException(Code)(Java Doc) public void setValue(boolean theValue) throws StandardException(Code)(Java Doc) public void setValue(byte[] theValue) throws StandardException(Code)(Java Doc) final public void setValue(DataValueDescriptor dvd) throws StandardException(Code)(Java Doc) public void setValue(InputStream theStream, int valueLength) throws StandardException(Code)(Java Doc) public void throwLangSetMismatch(Object value) throws StandardException(Code)(Java Doc) void throwLangSetMismatch(String argTypeName) throws StandardException(Code)(Java Doc) public int typePrecedence()(Code)(Java Doc) public int typeToBigDecimal() throws StandardException(Code)(Java Doc)
|
|
|