DBZ-696 Support nanoseconds in timestamp data
This commit is contained in:
parent
09b28c0913
commit
f844054f50
@ -77,7 +77,7 @@ public abstract class AbstractRecordsProducerTest {
|
||||
|
||||
protected static final String INSERT_CASH_TYPES_STMT = "INSERT INTO cash_table (csh) VALUES ('$1234.11')";
|
||||
protected static final String INSERT_DATE_TIME_TYPES_STMT = "INSERT INTO time_table(ts, tsneg, tz, date, ti, ttz, it) " +
|
||||
"VALUES ('2016-11-04T13:51:30'::TIMESTAMP, '1936-10-25T22:10:12.608'::TIMESTAMP, '2016-11-04T13:51:30+02:00'::TIMESTAMPTZ, " +
|
||||
"VALUES ('2016-11-04T13:51:30.123456'::TIMESTAMP, '1936-10-25T22:10:12.608'::TIMESTAMP, '2016-11-04T13:51:30+02:00'::TIMESTAMPTZ, " +
|
||||
"'2016-11-04'::DATE, '13:51:30'::TIME, '13:51:30+02:00'::TIMETZ, 'P1Y2M3DT4H5M0S'::INTERVAL)";
|
||||
protected static final String INSERT_BIN_TYPES_STMT = "INSERT INTO bitbin_table (ba, bol, bs, bv) " +
|
||||
"VALUES (E'\\\\001\\\\002\\\\003'::bytea, '0'::bit(1), '11'::bit(2), '00'::bit(2))";
|
||||
@ -294,7 +294,7 @@ protected List<SchemaAndValueField> schemaAndValuesForBinTypes() {
|
||||
}
|
||||
|
||||
protected List<SchemaAndValueField> schemaAndValuesForDateTimeTypes() {
|
||||
long expectedTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("2016-11-04T13:51:30"), null);
|
||||
long expectedTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("2016-11-04T13:51:30.123456"), null);
|
||||
long expectedNegTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("1936-10-25T22:10:12.608"), null);
|
||||
String expectedTz = "2016-11-04T11:51:30Z"; //timestamp is stored with TZ, should be read back with UTC
|
||||
int expectedDate = Date.toEpochDay(LocalDate.parse("2016-11-04"), null);
|
||||
@ -312,7 +312,7 @@ protected List<SchemaAndValueField> schemaAndValuesForDateTimeTypes() {
|
||||
}
|
||||
|
||||
protected List<SchemaAndValueField> schemaAndValuesForDateTimeTypesAdaptiveTimeMicroseconds() {
|
||||
long expectedTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("2016-11-04T13:51:30"), null);
|
||||
long expectedTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("2016-11-04T13:51:30.123456"), null);
|
||||
long expectedNegTs = NanoTimestamp.toEpochNanos(LocalDateTime.parse("1936-10-25T22:10:12.608"), null);
|
||||
String expectedTz = "2016-11-04T11:51:30Z"; //timestamp is stored with TZ, should be read back with UTC
|
||||
int expectedDate = Date.toEpochDay(LocalDate.parse("2016-11-04"), null);
|
||||
|
@ -133,6 +133,16 @@ protected static LocalDateTime toLocalDateTime(Object obj) {
|
||||
LocalTime localTime = toLocalTime(obj);
|
||||
return LocalDateTime.of(EPOCH, localTime);
|
||||
}
|
||||
if ( obj instanceof java.sql.Timestamp) {
|
||||
java.sql.Timestamp timestamp = (java.sql.Timestamp)obj;
|
||||
return LocalDateTime.of(timestamp.getYear() + 1900,
|
||||
timestamp.getMonth() + 1,
|
||||
timestamp.getDate(),
|
||||
timestamp.getHours(),
|
||||
timestamp.getMinutes(),
|
||||
timestamp.getSeconds(),
|
||||
timestamp.getNanos());
|
||||
}
|
||||
if ( obj instanceof java.util.Date) {
|
||||
java.util.Date date = (java.util.Date)obj;
|
||||
long millis = (int)(date.getTime() % Conversions.MILLISECONDS_PER_SECOND);
|
||||
|
Loading…
Reference in New Issue
Block a user