Skip to content

Commit

Permalink
Merge pull request #14 from taosdata/dev/zyyang
Browse files Browse the repository at this point in the history
fix: nullPointerException
  • Loading branch information
zyyang90 authored Feb 29, 2024
2 parents b653f2e + 7b78f15 commit 1b7c34f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/taosdata/demo/util/TimestampUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static String format(Object ts, String precision) {
if (ts instanceof Timestamp) {
return format((Timestamp) ts, precision);
}
return ts.toString();
return String.valueOf(ts);
}

public static String format(Timestamp ts, String precision) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/com/taosdata/demo/util/TimestampUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public void testFormatObject() {

actual = TimestampUtil.format(ts3, "ns");
assertEquals("2023-03-08 11:34:09.579123456", actual);

Object a = null;
actual = TimestampUtil.format(a, "ms");
assertEquals("null", actual);
}

@Test
Expand Down

0 comments on commit 1b7c34f

Please sign in to comment.