From 843a44dfe074a2b587ff4aacbd4089ab22e6f087 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 15 Dec 2018 06:13:06 +0000 Subject: switch expression engine to LocalDateTime git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jdk8@1238 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/DatabaseReadWriteTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/test/java/com/healthmarketscience/jackcess/impl/DatabaseReadWriteTest.java') diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/DatabaseReadWriteTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/DatabaseReadWriteTest.java index 561f1e8..104b266 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/DatabaseReadWriteTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/DatabaseReadWriteTest.java @@ -16,6 +16,9 @@ limitations under the License. package com.healthmarketscience.jackcess.impl; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -53,7 +56,7 @@ public class DatabaseReadWriteTest extends TestCase db.close(); } } - + public void testWriteAndReadInMem() throws Exception { for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) { Database db = createMem(fileFormat); @@ -61,7 +64,7 @@ public class DatabaseReadWriteTest extends TestCase db.close(); } } - + private static void doTestWriteAndRead(Database db) throws Exception { createTestTable(db); Object[] row = createTestRow(); @@ -117,7 +120,7 @@ public class DatabaseReadWriteTest extends TestCase } } - public void testUpdateRow() throws Exception + public void testUpdateRow() throws Exception { for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) { Database db = createMem(fileFormat); @@ -250,11 +253,18 @@ public class DatabaseReadWriteTest extends TestCase final long timeRange = 100000000L; final long timeStep = 37L; - for(long time = testTime - timeRange; time < testTime + timeRange; + for(long time = testTime - timeRange; time < testTime + timeRange; time += timeStep) { double accTime = ColumnImpl.toLocalDateDouble(time); long newTime = ColumnImpl.fromLocalDateDouble(accTime); assertEquals(time, newTime); + + Instant inst = Instant.ofEpochMilli(time); + LocalDateTime ldt = LocalDateTime.ofInstant(inst, ZoneOffset.UTC); + + accTime = ColumnImpl.toDateDouble(ldt); + LocalDateTime newLdt = ColumnImpl.ldtFromLocalDateDouble(accTime); + assertEquals(ldt, newLdt); } } } -- cgit v1.2.3