aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2008-01-15 15:44:04 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2008-01-15 15:44:04 +0000
commit5d9718216d85b6360214a12370a67970c6221574 (patch)
tree5157d15e87d58b06593a5dd4eca05c35c3a13e7a
parent683c1d5d4727a7a902d8058d79247798e75aebe6 (diff)
downloadjackcess-5d9718216d85b6360214a12370a67970c6221574.tar.gz
jackcess-5d9718216d85b6360214a12370a67970c6221574.zip
add some more date testing
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@215 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
index 091daf4..11b42d9 100644
--- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -38,6 +38,8 @@ import java.io.PrintWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.sql.Types;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -771,7 +773,44 @@ public class DatabaseTest extends TestCase {
db.close();
}
-
+
+ public void testWriteAndReadDate() throws Exception {
+ Database db = create();
+
+ List<Column> columns = new ArrayList<Column>();
+ Column col = new Column();
+ col.setName("name");
+ col.setType(DataType.TEXT);
+ columns.add(col);
+ col = new Column();
+ col.setName("date");
+ col.setType(DataType.SHORT_DATE_TIME);
+ columns.add(col);
+
+ db.createTable("test", columns);
+ Table table = db.getTable("test");
+
+ DateFormat df = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
+ List<Date> dates =
+ Arrays.asList(
+ df.parse("19801231 00:00:00"),
+ df.parse("19930513 14:43:27"),
+ null,
+ df.parse("20210102 02:37:00"),
+ new Date());
+
+ for(Date d : dates) {
+ table.addRow("row " + d, d);
+ }
+
+ List<Date> foundDates = new ArrayList<Date>();
+ for(Map<String,Object> row : table) {
+ foundDates.add((Date)row.get("date"));
+ }
+
+ assertEquals(dates, foundDates);
+ }
+
static Object[] createTestRow(String col1Val) {
return new Object[] {col1Val, "R", "McCune", 1234, (byte) 0xad, 555.66d,
777.88f, (short) 999, new Date()};