mirror of https://github.com/apache/nifi.git
NIFI-7208: Restore default timezone in JdbcCommon
This commit is contained in:
parent
0ad58200af
commit
ace5754524
|
@ -788,7 +788,7 @@ public class JdbcCommon {
|
|||
} else {
|
||||
final DateTimeFormatter dtFormatter = getDateTimeFormatter(valueFormat);
|
||||
LocalDateTime ldt = LocalDateTime.parse(parameterValue, dtFormatter);
|
||||
ts = Timestamp.from(ldt.atZone(ZoneId.of("UTC")).toInstant());
|
||||
ts = Timestamp.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
stmt.setTimestamp(parameterIndex, ts);
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -434,17 +435,19 @@ public class TestPutSQL {
|
|||
runner.enableControllerService(service);
|
||||
runner.setProperty(PutSQL.CONNECTION_POOL, "dbcp");
|
||||
|
||||
final String dateStr1 = "2002-02-02T12:02:02+00:00";
|
||||
final long dateInt1 = 1012651322000L;
|
||||
final String dateStr1 = "2002-02-02T12:02:02";
|
||||
final String dateStrTimestamp1 = "2002-02-02 12:02:02";
|
||||
final long dateInt1 = Timestamp.valueOf(dateStrTimestamp1).getTime();
|
||||
|
||||
final String dateStr2 = "2002-02-02T12:02:02.123456789";
|
||||
final long dateInt2 = 1012651322123L;
|
||||
final String dateStrTimestamp2 = "2002-02-02 12:02:02.123456789";
|
||||
final long dateInt2 = Timestamp.valueOf(dateStrTimestamp2).getTime();
|
||||
final long nanoInt2 = 123456789L;
|
||||
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
attributes.put("sql.args.1.type", String.valueOf(Types.TIMESTAMP));
|
||||
attributes.put("sql.args.1.value", dateStr1);
|
||||
attributes.put("sql.args.1.format", "ISO_OFFSET_DATE_TIME");
|
||||
attributes.put("sql.args.1.format", "ISO_LOCAL_DATE_TIME");
|
||||
attributes.put("sql.args.2.type", String.valueOf(Types.TIMESTAMP));
|
||||
attributes.put("sql.args.2.value", dateStr2);
|
||||
attributes.put("sql.args.2.format", "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS");
|
||||
|
|
Loading…
Reference in New Issue