ORC-528: Add unittest for timestamp off-by-one issues

Fixes #434

Signed-off-by: Owen O'Malley <omalley@apache.org>
diff --git a/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java b/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
index 02fc4dc..f839513 100644
--- a/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
+++ b/java/tools/src/test/org/apache/orc/tools/convert/TestJsonReader.java
@@ -45,4 +45,31 @@
         assertEquals("2018-03-21 12:23:34.123456", cv.asScratchTimestamp(0).toString());
         assertEquals("2018-02-03 18:04:51.456789", cv.asScratchTimestamp(1).toString());
     }
+
+    @Test
+    public void testTimestampOffByOne() throws Exception {
+        String tsFormat = "yyyy-MM-dd HH:mm:ss.SSSS";
+
+        String s = "{\"a\": \"1970-01-01 00:00:00.0001\"}\n" +
+                "{\"a\": \"1970-01-01 00:00:00.0000\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.9999\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.0001\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:59.0000\"}\n" +
+                "{\"a\": \"1969-12-31 23:59:58.9999\"}";
+        StringReader input = new StringReader(s);
+        TypeDescription schema = TypeDescription.fromString(
+                "struct<a:timestamp>");
+        JsonReader reader = new JsonReader(input, null, 1, schema, tsFormat);
+        VectorizedRowBatch batch = schema.createRowBatch(6);
+        assertEquals(true, reader.nextBatch(batch));
+        assertEquals(6, batch.size);
+        TimestampColumnVector cv = (TimestampColumnVector) batch.cols[0];
+        assertEquals("1970-01-01 00:00:00.0001", cv.asScratchTimestamp(0).toString());
+        assertEquals("1970-01-01 00:00:00.0", cv.asScratchTimestamp(1).toString());
+        assertEquals("1969-12-31 23:59:59.9999", cv.asScratchTimestamp(2).toString());
+        assertEquals("1969-12-31 23:59:59.0001", cv.asScratchTimestamp(3).toString());
+        assertEquals("1969-12-31 23:59:59.0", cv.asScratchTimestamp(4).toString());
+        assertEquals("1969-12-31 23:59:58.9999", cv.asScratchTimestamp(5).toString());
+    }
+
 }