|
Draft 01/30/01 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.converters.DateTime
High performance converters from date/time byte encodings to JDBC Date, Time and Timestamp objects.
Using this class for direct date/time conversions from bytes offers superior
performance over the alternative method of first constructing a Java String from
the encoded bytes, and then using java.sql.Date.valueOf()
,
java.sql.Time.valueOf()
or java.sql.Timestamp.valueOf()
.
These DateTime converters also allow for a variation of the ISO date/time
representations used by DB2 which is not supported by
java.sql.Date.valueOf()
, java.sql.Time.valueOf()
or
java.sql.Timestamp.valueOf()
. For example, both
hh.mm.ss
or the ISO representation hh:mm:ss
is
supported for time bytes.
Common encodings are special cased to bypass any String constructor calls
altogether. For the uncommon encodings, Unicode character arithmetic is used
rather than the less efficient Integer.parseInt (date.substring())
used by java.sql.Date.valueOf()
,
java.sql.Time.valueOf()
and
java.sql.Timestamp.valueOf()
.
For EBCDIC the Java encoding name is Cp500
. For a complete list
of supported encodings and their CCSID equivalents see CCSID To Java Encoding
Mapping.
Method Summary | |
static Date |
dateBytesToDate(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is of the form yyyy-mm-dd . |
static Timestamp |
dateBytesToTimestamp(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is of the form yyyy-mm-dd . |
static Time |
timeBytesToTime(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is either of the form hh.mm.ss or
the ISO representation hh:mm:ss . |
static Timestamp |
timeBytesToTimestamp(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is either of the form hh.mm.ss or
the ISO representation hh:mm:ss . |
static Date |
timestampBytesToDate(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is of the form yyyy-mm-dd-hh.mm.ss.ffffff or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff . |
static Time |
timestampBytesToTime(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is of the form yyyy-mm-dd-hh.mm.ss.ffffff or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff . |
static Timestamp |
timestampBytesToTimestamp(byte[] buffer,
int offset, int length, String encoding)
Expected character representation is of the form yyyy-mm-dd-hh.mm.ss.ffffff or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff . |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static Date dateBytesToDate(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
yyyy-mm-dd
.
So for a single-byte character encoding, the length should be 10.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Timestamp dateBytesToTimestamp(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
yyyy-mm-dd
.
So for a single-byte character encoding, the length should be 10.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Time timeBytesToTime(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
hh.mm.ss
or the ISO representation hh:mm:ss
. So for
a single-byte character encoding, the length should be 8.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Timestamp timeBytesToTimestamp(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
hh.mm.ss
or the ISO representation hh:mm:ss
. So for
a single-byte character encoding, the length should be 8.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Timestamp timestampBytesToTimestamp(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
yyyy-mm-dd-hh.mm.ss.ffffff
or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff
. So for a single-byte character
encoding, the length should be 26.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Date timestampBytesToDate(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
yyyy-mm-dd-hh.mm.ss.ffffff
or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff
. So for a single-byte character
encoding, the length should be 26.
UnsupportedEncodingException
- if the provided character encoding is unsupported.public static Time timestampBytesToTime(byte[] buffer, int offset, int length, String encoding) throws UnsupportedEncodingException
yyyy-mm-dd-hh.mm.ss.ffffff
or the ISO representation
yyyy-mm-dd hh:mm:ss.ffffff
. So for a single-byte character
encoding, the length should be 26.
UnsupportedEncodingException
- if the provided character encoding is unsupported.
|
Draft 01/30/01 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |