mirror of https://github.com/apache/nifi.git
NIFI-11367 Database DATE value displayed incorrectly in record output if timezone is GMT-X
This closes #7103. Signed-off-by: Peter Turcsanyi <turcsanyi@apache.org>
This commit is contained in:
parent
f0c9f3f892
commit
a36040fded
|
@ -19,7 +19,6 @@ package org.apache.nifi.serialization.record;
|
|||
|
||||
import org.apache.nifi.serialization.SimpleRecordSchema;
|
||||
import org.apache.nifi.serialization.record.type.ArrayDataType;
|
||||
import org.apache.nifi.serialization.record.util.DataTypeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -158,12 +157,6 @@ public class ResultSetRecordSet implements RecordSet, Closeable {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (value instanceof java.sql.Date) {
|
||||
// Date objects should be stored in records as UTC normalized dates (UTC 00:00:00)
|
||||
// but they come from the driver in JVM's local time zone 00:00:00 and need to be converted.
|
||||
return DataTypeUtils.convertDateToUTC((java.sql.Date) value);
|
||||
}
|
||||
|
||||
if (value instanceof List) {
|
||||
return ((List) value).toArray();
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.sql.Timestamp;
|
|||
import java.sql.Types;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -310,9 +309,7 @@ public class ResultSetRecordSetTest {
|
|||
assertEquals(booleanValue, record.getAsBoolean(COLUMN_NAME_BOOLEAN));
|
||||
assertEquals(charValue, record.getValue(COLUMN_NAME_CHAR));
|
||||
|
||||
// Date is expected in UTC normalized form
|
||||
Date expectedDate = new Date(testDate.atStartOfDay(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
assertEquals(expectedDate, record.getAsDate(COLUMN_NAME_DATE, null));
|
||||
assertEquals(dateValue, record.getAsDate(COLUMN_NAME_DATE, null));
|
||||
assertEquals(timestampValue, DataTypeUtils.toTimestamp(record.getValue(COLUMN_NAME_TIMESTAMP), null, COLUMN_NAME_TIMESTAMP));
|
||||
|
||||
assertEquals(integerValue, record.getAsInt(COLUMN_NAME_INTEGER));
|
||||
|
|
Loading…
Reference in New Issue