public class DateTime
extends java.lang.Object
java.sql.Date.valueOf(), java.sql.Time.valueOf() or java.sql.Timestamp.valueOf().
| Modifier and Type | Field and Description |
|---|---|
private static int |
dateRepresentationLength |
private static int |
timeRepresentationLength |
private static int |
timestampRepresentationLength |
| Modifier | Constructor and Description |
|---|---|
private |
DateTime() |
| Modifier and Type | Method and Description |
|---|---|
static java.sql.Date |
dateBytesToDate(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
Expected character representation is DERBY string representation of a date,
which is in JIS format:
yyyy-mm-dd |
static java.sql.Timestamp |
dateBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
Expected character representation is DERBY string representation of a date
which is in JIS format:
yyyy-mm-dd |
static int |
dateToDateBytes(byte[] buffer,
int offset,
DateTimeValue date)
Date is converted to a char representation in JDBC date format:
yyyy-mm-dd date format
and then converted to bytes using UTF8 encoding |
private static java.util.Calendar |
getCleanCalendar(java.util.Calendar recyclableCal)
Return a clean (i.e. all values cleared out) Calendar object
that can be used for creating Time, Timestamp, and Date objects.
|
static int |
getTimestampLength(boolean supportsTimestampNanoseconds)
Return the length of a timestamp depending on whether timestamps
should have full nanosecond precision or be truncated to just microseconds.
|
private static int |
parseTimestampString(java.lang.String timestamp,
java.util.Calendar cal,
boolean supportsTimestampNanoseconds)
Parse a String of the form
yyyy-mm-dd-hh.mm.ss.ffffff[fff]
and store the various fields into the received Calendar object. |
static java.sql.Time |
timeBytesToTime(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
Expected character representation is DERBY string representation of time,
which is in the format:
hh.mm.ss |
static java.sql.Timestamp |
timeBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
Expected character representation is DERBY string representation of time
which is in the format:
hh.mm.ss |
static java.sql.Date |
timestampBytesToDate(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
See getTimestampLength() for an explanation of how timestamps are formatted.
|
static java.sql.Time |
timestampBytesToTime(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
See getTimestampLength() for an explanation of how timestamps are formatted.
|
static java.sql.Timestamp |
timestampBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding,
boolean supportsTimestampNanoseconds)
See getTimestampLength() for an explanation of how timestamps are formatted.
|
static int |
timestampToTimestampBytes(byte[] buffer,
int offset,
DateTimeValue timestamp,
boolean supportsTimestampNanoseconds)
See getTimestampLength() for an explanation of how timestamps are formatted.
|
static int |
timeToTimeBytes(byte[] buffer,
int offset,
DateTimeValue time)
java.sql.Time is converted to character representation which is in JDBC time escape
format:
hh:mm:ss, which is the same as JIS time format in DERBY string
representation of a time. |
private static final int dateRepresentationLength
private static final int timeRepresentationLength
private static final int timestampRepresentationLength
public static final java.sql.Date dateBytesToDate(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
yyyy-mm-dd buffer - offset - recyclableCal - encoding - encoding of buffer datajava.io.UnsupportedEncodingExceptionpublic static final java.sql.Time timeBytesToTime(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
hh.mm.ss buffer - offset - recyclableCal - encoding - encoding of bufferjava.io.UnsupportedEncodingExceptionpublic static final java.sql.Timestamp timestampBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding,
boolean supportsTimestampNanoseconds)
throws java.io.UnsupportedEncodingException
buffer - offset - recyclableCal - encoding - encoding of buffersupportsTimestampNanoseconds - true if the server supports nanoseconds in timestampsjava.io.UnsupportedEncodingExceptionprivate static int parseTimestampString(java.lang.String timestamp,
java.util.Calendar cal,
boolean supportsTimestampNanoseconds)
yyyy-mm-dd-hh.mm.ss.ffffff[fff]
and store the various fields into the received Calendar object.timestamp - Timestamp value to parse, as a String.cal - Calendar into which to store the parsed fields. Should not be null.supportsTimestampNanoseconds - true if the server supports nanoseconds in timestampspublic static final int dateToDateBytes(byte[] buffer,
int offset,
DateTimeValue date)
throws SqlException,
java.io.UnsupportedEncodingException
yyyy-mm-dd date format
and then converted to bytes using UTF8 encodingbuffer - bytes in UTF8 encoding of the dateoffset - write into the buffer from this offsetdate - date valueSqlExceptionjava.io.UnsupportedEncodingException - if UTF8 Encoding is not supportedpublic static final int timeToTimeBytes(byte[] buffer,
int offset,
DateTimeValue time)
throws java.io.UnsupportedEncodingException
hh:mm:ss, which is the same as JIS time format in DERBY string
representation of a time. The char representation is converted to bytes using UTF8
encoding.buffer - bytes in UTF8 encoding of the timeoffset - write into the buffer from this offsettime - java.sql.Time valuejava.io.UnsupportedEncodingExceptionpublic static final int timestampToTimestampBytes(byte[] buffer,
int offset,
DateTimeValue timestamp,
boolean supportsTimestampNanoseconds)
throws SqlException,
java.io.UnsupportedEncodingException
buffer - bytes in UTF8 encoding of the timestampoffset - write into the buffer from this offsettimestamp - timestamp valuesupportsTimestampNanoseconds - true if the server supports nanoseconds in timestampsSqlExceptionjava.io.UnsupportedEncodingExceptionpublic static final java.sql.Timestamp dateBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
yyyy-mm-dd buffer - offset - recyclableCal - encoding - encoding of bufferjava.io.UnsupportedEncodingExceptionpublic static final java.sql.Timestamp timeBytesToTimestamp(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
hh.mm.ss buffer - offset - recyclableCal - encoding - encoding of bufferjava.io.UnsupportedEncodingExceptionpublic static final java.sql.Date timestampBytesToDate(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
buffer - offset - recyclableCal - encoding - encoding of bufferjava.io.UnsupportedEncodingExceptionpublic static final java.sql.Time timestampBytesToTime(byte[] buffer,
int offset,
java.util.Calendar recyclableCal,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
buffer - offset - recyclableCal - encoding - encoding of bufferjava.io.UnsupportedEncodingExceptionprivate static java.util.Calendar getCleanCalendar(java.util.Calendar recyclableCal)
recyclableCal - Calendar object to use if non-null.public static int getTimestampLength(boolean supportsTimestampNanoseconds)
yyyy-mm-dd-hh.mm.ss.fffffffff.
For Derby 10.5 and below, this is yyyy-mm-dd-hh.mm.ss.ffffff. See DERBY-2602.
and then converted to bytes using UTF8 encodingsupportsTimestampNanoseconds - true if the connection supports nanoseconds in timestampsApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.