-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update getKustoDateTime with more lenient formatter (#246)
* Update getKustoDateTime with more lenient formatter * Convert DateTimeFormatter to static * Add additional tests for getKustoDateTime Co-authored-by: AsafMah <[email protected]>
- Loading branch information
1 parent
15eaf2a
commit 2209318
Showing
3 changed files
with
68 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
data/src/test/java/com/microsoft/azure/kusto/data/KustoDateTimeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.microsoft.azure.kusto.data; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Instant; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneOffset; | ||
|
||
public class KustoDateTimeTest { | ||
@Test | ||
void KustoResultSet() throws Exception { | ||
JSONArray rows = new JSONArray(); | ||
JSONArray row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.1Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.12Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.123Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.1234Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.12345Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.123456Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.1234567Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.12345678Z")); | ||
rows.put(row); | ||
row = new JSONArray(); | ||
row.put(Instant.parse("2022-05-17T00:00:00.123456789Z")); | ||
rows.put(row); | ||
|
||
String columns = "[ { \"ColumnName\": \"a\", \"ColumnType\": \"datetime\" } ]"; | ||
KustoResultSetTable res = new KustoResultSetTable(new JSONObject("{\"TableName\":\"Table_0\"," + | ||
"\"Columns\":" + columns + ",\"Rows\":" + | ||
rows.toString() + "}")); | ||
|
||
Integer rowNum = 0; | ||
while (res.next()) | ||
{ | ||
Assertions.assertEquals( | ||
LocalDateTime.ofInstant((Instant)((JSONArray)rows.get(rowNum)).get(0), ZoneOffset.UTC), | ||
res.getKustoDateTime(0)); | ||
rowNum++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters