From 48a8a2db08329f64599b5ed73ccee54b1e718808 Mon Sep 17 00:00:00 2001 From: zyyang Date: Tue, 22 Dec 2020 11:15:52 +0800 Subject: [PATCH] change --- .../com/taosdata/taosdemo/utils/SqlSpeller.java | 17 +++++++++++++---- .../taosdemo/utils/TimeStampUtilTest.java | 3 --- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java index 349fbfdb7b..78489b0de7 100644 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java +++ b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; +import java.util.stream.IntStream; public class SqlSpeller { @@ -64,10 +65,18 @@ public class SqlSpeller { //f1, f2, f3 private static String fieldValues(List fields) { - return fields.stream() - .filter(Objects::nonNull) - .map(fieldValue -> "'" + fieldValue.getValue() + "'") - .collect(Collectors.joining(",", "(", ")")); + return IntStream.range(0, fields.size()).mapToObj(i -> { + if (i == 0) { + return "" + fields.get(i).getName() + ""; + } else { + return "'" + fields.get(i).getValue() + "'"; + } + }).collect(Collectors.joining(",", "(", ")")); + +// return fields.stream() +// .filter(Objects::nonNull) +// .map(fieldValue -> "'" + fieldValue.getValue() + "'") +// .collect(Collectors.joining(",", "(", ")")); } //(f1, f2, f3),(f1, f2, f3) diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java index 195db2b13e..628594c4b1 100644 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java +++ b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java @@ -17,9 +17,6 @@ public class TimeStampUtilTest { @Test public void longToDatetime() { - System.out.println(TimeStampUtil.longToDatetime(1293244920052l)); - - String datetime = TimeStampUtil.longToDatetime(1510000000000L); assertEquals("2017-11-07 04:26:40.000", datetime); long timestamp = TimeStampUtil.datetimeToLong(datetime); -- GitLab