polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [6/7] zest-java git commit: ZEST-124 - Replaced Joda Time API with Java Time API, and I also removed the java.util.Date support and all uses except where required when interfacing with other systems.
Date Sun, 12 Jun 2016 06:24:07 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
index 3a08c81..ce9d361 100644
--- a/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/value/AbstractValueCompositeSerializationTest.java
@@ -21,16 +21,16 @@ package org.apache.zest.test.value;
 
 import java.io.ByteArrayOutputStream;
 import java.io.Serializable;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.structure.Module;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
@@ -92,8 +92,7 @@ public abstract class AbstractValueCompositeSerializationTest
     public void givenValueCompositeWhenSerializingAndDeserializingExpectEquals()
         throws Exception
     {
-        UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
-        try
+        try(UnitOfWork uow = unitOfWorkFactory.newUnitOfWork())
         {
             SomeValue some = buildSomeValue();
 
@@ -103,25 +102,18 @@ public abstract class AbstractValueCompositeSerializationTest
             String stateString = output.toString( "UTF-8" );
 
             // Deserialize using Module API
+            System.out.println(stateString);
             SomeValue some2 = moduleInstance.newValueFromSerializedState( SomeValue.class, stateString );
 
-            assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
+            assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
+            assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
+            assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
+
             assertThat( "Same value", some, equalTo( some2 ) );
             assertThat( "Same JSON value toString", stateString, equalTo( some2.toString() ) );
             assertThat( "Same JSON value", some.customFoo().get() instanceof CustomFooValue, is( true ) );
             assertThat( "Same JSON value explicit", some.customFooValue().get() instanceof CustomFooValue, is( true ) );
-
-            assertThat( "String Integer Map", some2.stringIntMap().get().get( "foo" ), equalTo( 42 ) );
-            assertThat( "String Value Map", some2.stringValueMap().get().get( "foo" ).internalVal(), equalTo( "Bar" ) );
-            assertThat( "Nested Entities", some2.barAssociation().get().cathedral().get(), equalTo( "bazar in barAssociation" ) );
-        }
-        catch( Exception ex )
-        {
-            throw ex;
-        }
-        finally
-        {
-            uow.discard();
+            assertThat( "Same value toString", some.toString(), equalTo( some2.toString() ) );
         }
     }
 
@@ -151,13 +143,11 @@ public abstract class AbstractValueCompositeSerializationTest
         // proto.string().set( "Foo\"Bar\"\nTest\f\t\b" );
         proto.string().set( "Foo\"Bar\"\nTest\t" );
         proto.string2().set( "/Foo/bar" );
-        proto.number().set( 42L );
-        proto.date().set( new Date() );
-        // We specify the TimeZone explicitely here so that serialized/deserialized is equals
-        // See https://github.com/JodaOrg/joda-time/issues/106
-        proto.dateTime().set( new DateTime( "2020-03-04T13:24:35", DateTimeZone.forOffsetHours( 1 ) ) );
-        proto.localDate().set( new LocalDate() );
-        proto.localDateTime().set( new LocalDateTime() );
+        proto.number().set( 43L );
+        proto.localTime().set( LocalTime.now() );
+        proto.dateTime().set( OffsetDateTime.of( 2020, 3, 4, 13, 24, 35, 0, ZoneOffset.ofHours( 1 ) ) );
+        proto.localDate().set( LocalDate.now() );
+        proto.localDateTime().set( LocalDateTime.now() );
         proto.entityReference().set( EntityReference.parseEntityReference( "12345" ) );
         proto.stringIntMap().get().put( "foo", 42 );
 
@@ -240,9 +230,9 @@ public abstract class AbstractValueCompositeSerializationTest
         @UseDefaults
         Property<Long> number();
 
-        Property<Date> date();
+        Property<LocalTime> localTime();
 
-        Property<DateTime> dateTime();
+        Property<OffsetDateTime> dateTime();
 
         Property<LocalDate> localDate();
 
@@ -437,3 +427,5 @@ public abstract class AbstractValueCompositeSerializationTest
         }
     }
 }
+
+

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/def.xml
----------------------------------------------------------------------
diff --git a/def.xml b/def.xml
new file mode 100644
index 0000000..5a64c0b
--- /dev/null
+++ b/def.xml
@@ -0,0 +1,334 @@
+<?xml version='1.1' encoding='utf-8'?>
+<object>
+  <field>
+    <name>number</name>
+    <value>43</value>
+  </field>
+  <field>
+    <name>foo</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$FooValue</value>
+        </field>
+        <field>
+          <name>bar</name>
+          <value></value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>nullString</name>
+    <value>
+      <null/>
+    </value>
+  </field>
+  <field>
+    <name>anotherNull</name>
+    <value>
+      <null/>
+    </value>
+  </field>
+  <field>
+    <name>emptyString</name>
+    <value></value>
+  </field>
+  <field>
+    <name>testEnum</name>
+    <value>somevalue</value>
+  </field>
+  <field>
+    <name>stringList</name>
+    <value>
+      <array/>
+    </value>
+  </field>
+  <field>
+    <name>anotherListNull</name>
+    <value>
+      <null/>
+    </value>
+  </field>
+  <field>
+    <name>anotherListEmpty</name>
+    <value>
+      <array/>
+    </value>
+  </field>
+  <field>
+    <name>string</name>
+    <value>Foo&amp;quot;Bar&amp;quot;
+      Test
+    </value>
+  </field>
+  <field>
+    <name>stringIntMap</name>
+    <value>
+      <array>
+        <object>
+          <field>
+            <name>key</name>
+            <value>foo</value>
+          </field>
+          <field>
+            <name>value</name>
+            <value>42</value>
+          </field>
+        </object>
+      </array>
+    </value>
+  </field>
+  <field>
+    <name>stringValueMap</name>
+    <value>
+      <array>
+        <object>
+          <field>
+            <name>key</name>
+            <value>foo</value>
+          </field>
+          <field>
+            <name>value</name>
+            <value>
+              <object>
+                <field>
+                  <name>_type</name>
+                  <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+                </field>
+                <field>
+                  <name>val1</name>
+                  <value>Foo</value>
+                </field>
+                <field>
+                  <name>val2</name>
+                  <value>Bar</value>
+                </field>
+              </object>
+            </value>
+          </field>
+        </object>
+      </array>
+    </value>
+  </field>
+  <field>
+    <name>customFoo</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$CustomFooValue</value>
+        </field>
+        <field>
+          <name>custom</name>
+          <value></value>
+        </field>
+        <field>
+          <name>bar</name>
+          <value></value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>customFooValue</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$CustomFooValue</value>
+        </field>
+        <field>
+          <name>custom</name>
+          <value></value>
+        </field>
+        <field>
+          <name>bar</name>
+          <value></value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>anotherList</name>
+    <value>
+      <array>
+        <value>
+          <object>
+            <field>
+              <name>_type</name>
+              <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+            </field>
+            <field>
+              <name>val1</name>
+              <value></value>
+            </field>
+            <field>
+              <name>val2</name>
+              <value></value>
+            </field>
+          </object>
+        </value>
+      </array>
+    </value>
+  </field>
+  <field>
+    <name>specificCollection</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$SpecificCollection</value>
+        </field>
+        <field>
+          <name>genericList</name>
+          <value>
+            <array>
+              <value>Some</value>
+              <value>String</value>
+            </array>
+          </value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>string2</name>
+    <value>/Foo/bar</value>
+  </field>
+  <field>
+    <name>localTime</name>
+    <value>17:24:12.627</value>
+  </field>
+  <field>
+    <name>dateTime</name>
+    <value>2020-03-04T13:24:35+01:00</value>
+  </field>
+  <field>
+    <name>localDate</name>
+    <value>2016-06-11</value>
+  </field>
+  <field>
+    <name>localDateTime</name>
+    <value>2016-06-11T17:24:12.627</value>
+  </field>
+  <field>
+    <name>entityReference</name>
+    <value>12345</value>
+  </field>
+  <field>
+    <name>another</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$AnotherValue</value>
+        </field>
+        <field>
+          <name>val1</name>
+          <value>Foo</value>
+        </field>
+        <field>
+          <name>val2</name>
+          <value>Bar</value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>serializable</name>
+    <value>
+      rO0ABXNyAFVvcmcuYXBhY2hlLnplc3QudGVzdC52YWx1ZS5BYnN0cmFjdFZhbHVlQ29tcG9zaXRlU2VyaWFsaXphdGlvblRlc3QkU2VyaWFsaXphYmxlT2JqZWN0AAAAAAAAAAECAAJJAAN2YWxMAANmb290ABJMamF2YS9sYW5nL1N0cmluZzt4cAAAACN0AANGb28=
+    </value>
+  </field>
+  <field>
+    <name>fooValue</name>
+    <value>
+      <object>
+        <field>
+          <name>_type</name>
+          <value>org.apache.zest.test.value.AbstractValueCompositeSerializationTest$FooValue</value>
+        </field>
+        <field>
+          <name>bar</name>
+          <value></value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>barAssociationOptional</name>
+    <value>
+      <null/>
+    </value>
+  </field>
+  <field>
+    <name>barAssociation</name>
+    <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-0</value>
+  </field>
+  <field>
+    <name>barEntityAssociation</name>
+    <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-1</value>
+  </field>
+  <field>
+    <name>barManyAssociationEmpty</name>
+    <value>
+      <array/>
+    </value>
+  </field>
+  <field>
+    <name>barManyAssociation</name>
+    <value>
+      <array>
+        <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-2</value>
+        <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-3</value>
+      </array>
+    </value>
+  </field>
+  <field>
+    <name>barEntityManyAssociation</name>
+    <value>
+      <array>
+        <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-4</value>
+        <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-5</value>
+      </array>
+    </value>
+  </field>
+  <field>
+    <name>barNamedAssociationEmpty</name>
+    <value>
+      <object/>
+    </value>
+  </field>
+  <field>
+    <name>barNamedAssociation</name>
+    <value>
+      <object>
+        <field>
+          <name>bazar</name>
+          <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-6</value>
+        </field>
+        <field>
+          <name>cathedral</name>
+          <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-7</value>
+        </field>
+      </object>
+    </value>
+  </field>
+  <field>
+    <name>barEntityNamedAssociation</name>
+    <value>
+      <object>
+        <field>
+          <name>bazar</name>
+          <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-8</value>
+        </field>
+        <field>
+          <name>cathedral</name>
+          <value>8e813879-6aac-463a-bacf-cb2b5ab2e79e-9</value>
+        </field>
+      </object>
+    </value>
+  </field>
+</object>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
index 4da0b31..0932df0 100644
--- a/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
+++ b/extensions/indexing-rdf/src/main/java/org/apache/zest/index/rdf/query/internal/RdfQueryParserImpl.java
@@ -23,7 +23,6 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -70,17 +69,6 @@ import static java.lang.String.format;
 public class RdfQueryParserImpl
     implements RdfQueryParser
 {
-    private static final ThreadLocal<DateFormat> ISO8601_UTC = new ThreadLocal<DateFormat>()
-    {
-        @Override
-        protected DateFormat initialValue()
-        {
-            SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
-            dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
-            return dateFormat;
-        }
-    };
-
     private static final Map<Class<? extends ComparisonPredicate>, String> OPERATORS;
     private static final Set<Character> RESERVED_CHARS;
 
@@ -555,16 +543,11 @@ public class RdfQueryParserImpl
         {
             return null;
         }
-
-        if( value instanceof Date )
-        {
-            return ISO8601_UTC.get().format( (Date) value );
-        }
-        else if( value instanceof EntityComposite )
+        if( value instanceof EntityComposite )
         {
             return "urn:zest:entity:" + value.toString();
         }
-        else if( value instanceof Variable )
+        if( value instanceof Variable )
         {
             Object realValue = variables.get( ( (Variable) value ).variableName() );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
index 7a7bbb9..c34ff0b 100644
--- a/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
+++ b/extensions/indexing-solr/src/main/java/org/apache/zest/index/solr/internal/SolrEntityIndexerMixin.java
@@ -22,7 +22,6 @@ package org.apache.zest.index.solr.internal;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -149,7 +148,7 @@ public abstract class SolrEntityIndexerMixin
         SolrInputDocument input = new SolrInputDocument();
         input.addField( "id", entityState.identity().identity() );
         input.addField( "type", entityState.entityDescriptor().types().findFirst().get().getName() );
-        input.addField( "lastModified", new Date( entityState.lastModified() ) );
+        input.addField( "lastModified", entityState.lastModified() );
 
         for( Statement statement : graph )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
index 807cea6..8f6d029 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/common/QNameInfo.java
@@ -21,9 +21,16 @@ package org.apache.zest.index.sql.support.common;
 
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Date;
 import java.util.List;
 import org.apache.zest.api.association.AssociationDescriptor;
 import org.apache.zest.api.common.QualifiedName;
@@ -109,7 +116,14 @@ public final class QNameInfo
                 Number.class.isAssignableFrom( finalClass )//
                 || Boolean.class.isAssignableFrom( finalClass ) //
                 || Character.class.isAssignableFrom( finalClass ) //
-                || Date.class.isAssignableFrom( finalClass ) //
+                || LocalDate.class.isAssignableFrom( finalClass ) //
+                || LocalTime.class.isAssignableFrom( finalClass ) //
+                || LocalDateTime.class.isAssignableFrom( finalClass ) //
+                || ZonedDateTime.class.isAssignableFrom( finalClass ) //
+                || OffsetDateTime.class.isAssignableFrom( finalClass ) //
+                || Instant.class.isAssignableFrom( finalClass ) //
+                || Duration.class.isAssignableFrom( finalClass ) //
+                || Period.class.isAssignableFrom( finalClass ) //
                 || Enum.class.isAssignableFrom( finalClass ) //
                 || String.class.isAssignableFrom( finalClass )//
                 ;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
index fb58c78..4f82bec 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/postgresql/PostgreSQLTypeHelper.java
@@ -24,7 +24,6 @@ import java.lang.reflect.Type;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Timestamp;
-import java.util.Date;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
@@ -72,10 +71,10 @@ public interface PostgreSQLTypeHelper
                         (Character) primitive
                     }, 0 );
                 }
-                else if( primitive instanceof Date )
-                {
-                    primitive = new Timestamp( ( (Date) primitive ).getTime() );
-                }
+//                else if( primitive instanceof Date )
+//                {
+//                    primitive = new Timestamp( ( (Date) primitive ).getTime() );
+//                }
                 else if( primitive instanceof Byte )
                 {
                     primitive = (short) (Byte) primitive;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
index bd69d6c..a733f36 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLStartup.java
@@ -29,9 +29,16 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Deque;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -291,7 +298,12 @@ public abstract class AbstractSQLStartup
         this._primitiveTypes.put( Long.class, dt.bigInt() );
         this._primitiveTypes.put( Float.class, dt.real() );
         this._primitiveTypes.put( Double.class, dt.doublePrecision() );
-        this._primitiveTypes.put( Date.class, dt.timeStamp( true ) );
+        this._primitiveTypes.put( LocalDate.class, dt.timeStamp( false ) );
+        this._primitiveTypes.put( LocalTime.class, dt.timeStamp( false ) );
+        this._primitiveTypes.put( LocalDateTime.class, dt.timeStamp( false ) );
+        this._primitiveTypes.put( ZonedDateTime.class, dt.timeStamp( true ) );
+        this._primitiveTypes.put( OffsetDateTime.class, dt.timeStamp( true ) );
+        this._primitiveTypes.put( Instant.class, dt.timeStamp( true ) );
         this._primitiveTypes.put( Character.class, dt.integer() );
         this._primitiveTypes.put( String.class, dt.sqlVarChar( 5000 ) );
         this._primitiveTypes.put( BigInteger.class, dt.decimal() );
@@ -305,7 +317,13 @@ public abstract class AbstractSQLStartup
         jdbcTypes.put( Long.class, Types.BIGINT );
         jdbcTypes.put( Float.class, Types.REAL );
         jdbcTypes.put( Double.class, Types.DOUBLE );
-        jdbcTypes.put( Date.class, Types.TIMESTAMP );
+        jdbcTypes.put( Instant.class, Types.TIMESTAMP );
+        jdbcTypes.put( LocalDate.class, Types.DATE );
+        jdbcTypes.put( LocalTime.class, Types.TIME );
+        jdbcTypes.put( ZonedDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE );
+        jdbcTypes.put( OffsetDateTime.class, Types.TIMESTAMP_WITH_TIMEZONE );
+        jdbcTypes.put( Duration.class, Types.VARCHAR);
+        jdbcTypes.put( Period.class, Types.VARCHAR);
         jdbcTypes.put( Character.class, Types.INTEGER );
         jdbcTypes.put( String.class, Types.VARCHAR );
         jdbcTypes.put( BigInteger.class, Types.NUMERIC );
@@ -533,7 +551,7 @@ public abstract class AbstractSQLStartup
                             .addTableElement( d.createColumnDefinition( ENTITY_TABLE_IDENTITY_COLUMN_NAME, this._primitiveTypes
                                 .get( String.class ), false ) )
                             .addTableElement( d.createColumnDefinition( ENTITY_TABLE_MODIFIED_COLUMN_NAME, this._primitiveTypes
-                                .get( Date.class ), false ) )
+                                .get( Instant.class ), false ) )
                             .addTableElement( d.createColumnDefinition( ENTITY_TABLE_VERSION_COLUMN_NAME, this._primitiveTypes
                                 .get( String.class ), false ) )
                             .addTableElement( d.createColumnDefinition( ENTITY_TABLE_APPLICATION_VERSION_COLUMN_NAME, this._primitiveTypes

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
----------------------------------------------------------------------
diff --git a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
index a916a6a..5589467 100644
--- a/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
+++ b/extensions/valueserialization-jackson/src/main/java/org/apache/zest/valueserialization/jackson/JacksonValueDeserializer.java
@@ -207,8 +207,8 @@ public class JacksonValueDeserializer
         }
         if( token != JsonToken.START_OBJECT )
         {
-            throw new ValueSerializationException( "Expected an object start at "
-                                                   + input.getCurrentLocation().toString() );
+            String message = "Expected an object start at " + input.getCurrentLocation().toString();
+            throw new ValueSerializationException( message );
         }
         return (ObjectNode) input.readValueAsTree();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 0dfe3fc..a185e61 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -42,7 +42,6 @@ def jedisVersion = '2.7.2'
 def jettyVersion = '9.2.11.v20150529' // 9.3.x Tests fail!
 def jgoodiesLooksVersion = '2.5.3'
 def jodaMoneyVersion = '0.10.0'
-def jodaTimeVersion = '2.8.1'
 def jtaVersion = '1.1'
 def leveldbVersion = '0.7'
 def leveldbJniVersion = '1.8'
@@ -192,7 +191,6 @@ rootProject.ext {
           // Library & Extension dependencies
           jackson_mapper: "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
           jodamoney: "org.joda:joda-money:$jodaMoneyVersion",
-          jodatime: "joda-time:joda-time:$jodaTimeVersion",
           ehcache: "net.sf.ehcache:ehcache:$ehcacheVersion",
           elasticsearch: "org.elasticsearch:elasticsearch:$elasticsearchVersion",
           h2: "com.h2database:h2:$h2Version",

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
index 2b387e4..b531efe 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmEvent.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.alarm;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import org.apache.zest.api.injection.scope.Service;
@@ -64,7 +64,7 @@ public interface AlarmEvent
      *
      * @return the timestamp when this event occurred.
      */
-    Property<Date> eventTime();
+    Property<Instant> eventTime();
 
     /**
      * Returns the Name of the event.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
index b370702..a4f9ee9 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmStatus.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.alarm;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.Locale;
 import java.util.ResourceBundle;
 import org.apache.zest.api.common.Optional;
@@ -62,7 +62,7 @@ public interface AlarmStatus extends ValueComposite
          * @return the timestamp of when the state was created.
          */
         @Optional
-        Property<Date> creationDate();
+        Property<Instant> creationDate();
 
         /**
          * Returns the Name of the AlarmStatus.
@@ -103,7 +103,7 @@ public interface AlarmStatus extends ValueComposite
         {
             if( state.creationDate().get() == null )
             {
-                state.creationDate().set( new Date() );
+                state.creationDate().set( Instant.now() );
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
index e6a950b..b848c6a 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/AlarmSystem.java
@@ -20,8 +20,8 @@
 
 package org.apache.zest.library.alarm;
 
+import java.time.Instant;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -226,7 +226,7 @@ public interface AlarmSystem
             ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
             AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
             statePrototype.name().set( status );
-            statePrototype.creationDate().set( new Date() );
+            statePrototype.creationDate().set( Instant.now() );
             return builder.newInstance();
         }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
index 853391e..3bd5c3a 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/ExtendedAlarmModelService.java
@@ -19,9 +19,9 @@
  */
 package org.apache.zest.library.alarm;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -408,7 +408,7 @@ public interface ExtendedAlarmModelService
             ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
             AlarmStatus.State prototype = builder.prototypeFor(AlarmStatus.State.class);
             prototype.name().set( status );
-            prototype.creationDate().set( new Date() );
+            prototype.creationDate().set( Instant.now() );
             return builder.newInstance();
         }
 
@@ -421,7 +421,7 @@ public interface ExtendedAlarmModelService
             ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
             AlarmEvent prototype = builder.prototype();
             prototype.alarmIdentity().set( alarmId.identity().get() );
-            prototype.eventTime().set( new Date() );
+            prototype.eventTime().set( Instant.now() );
             prototype.newStatus().set( newStatus );
             prototype.oldStatus().set( oldStatus );
             prototype.systemName().set( eventSystemName );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
index 004e541..8f9e7dc 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/SimpleAlarmModelService.java
@@ -19,9 +19,9 @@
  */
 package org.apache.zest.library.alarm;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -231,7 +231,7 @@ public interface SimpleAlarmModelService extends AlarmModel, ServiceComposite
             ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
             AlarmStatus.State prototype = builder.prototypeFor(AlarmStatus.State.class);
             prototype.name().set( status );
-            prototype.creationDate().set( new Date() );
+            prototype.creationDate().set( Instant.now() );
             return builder.newInstance();
         }
 
@@ -243,7 +243,7 @@ public interface SimpleAlarmModelService extends AlarmModel, ServiceComposite
             ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
             AlarmEvent prototype = builder.prototype();
             prototype.alarmIdentity().set( alarmId.identity().get() );
-            prototype.eventTime().set( new Date() );
+            prototype.eventTime().set( Instant.now() );
             prototype.newStatus().set( newStatus );
             prototype.oldStatus().set( oldStatus );
             prototype.systemName().set( eventSystemName );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
index be5b9c2..91a28aa 100644
--- a/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
+++ b/libraries/alarm/src/main/java/org/apache/zest/library/alarm/StandardAlarmModelService.java
@@ -19,9 +19,9 @@
  */
 package org.apache.zest.library.alarm;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -276,7 +276,7 @@ public interface StandardAlarmModelService extends AlarmModel, ServiceComposite
             ValueBuilder<AlarmStatus> builder = vbf.newValueBuilder( AlarmStatus.class );
             AlarmStatus.State prototype = builder.prototypeFor( AlarmStatus.State.class );
             prototype.name().set( status );
-            prototype.creationDate().set( new Date() );
+            prototype.creationDate().set( Instant.now() );
             return builder.newInstance();
         }
 
@@ -289,7 +289,7 @@ public interface StandardAlarmModelService extends AlarmModel, ServiceComposite
             ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder( AlarmEvent.class );
             AlarmEvent prototype = builder.prototype();
             prototype.alarmIdentity().set( alarmId.identity().get() );
-            prototype.eventTime().set( new Date() );
+            prototype.eventTime().set( Instant.now() );
             prototype.newStatus().set( newStatus );
             prototype.oldStatus().set( oldStatus );
             prototype.systemName().set( eventSystemName );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
index 6a05ad9..4fd6599 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/ExtendedAlarmModelTest.java
@@ -19,7 +19,7 @@
  */
 package org.apache.zest.library.alarm;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.List;
 import java.util.Locale;
 import org.junit.Test;
@@ -972,7 +972,7 @@ public class ExtendedAlarmModelTest
         ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
         AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
         statePrototype.name().set( status );
-        statePrototype.creationDate().set( new Date() );
+        statePrototype.creationDate().set( Instant.now() );
         return builder.newInstance();
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
index da8cac1..ae68817 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/SimpleAlarmModelTest.java
@@ -19,7 +19,7 @@
  */
 package org.apache.zest.library.alarm;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.List;
 import java.util.Locale;
 import org.junit.Test;
@@ -357,7 +357,7 @@ public class SimpleAlarmModelTest
         ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
         AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
         statePrototype.name().set( status );
-        statePrototype.creationDate().set( new Date() );
+        statePrototype.creationDate().set( Instant.now() );
         return builder.newInstance();
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
----------------------------------------------------------------------
diff --git a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
index 1fd8379..0fc022a 100644
--- a/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
+++ b/libraries/alarm/src/test/java/org/apache/zest/library/alarm/StandardAlarmModelTest.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.alarm;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.List;
 import java.util.Locale;
 import org.junit.Assert;
@@ -484,7 +484,7 @@ public class StandardAlarmModelTest
         ValueBuilder<AlarmStatus> builder = valueBuilderFactory.newValueBuilder( AlarmStatus.class );
         AlarmStatus.State statePrototype = builder.prototypeFor( AlarmStatus.State.class );
         statePrototype.name().set( status );
-        statePrototype.creationDate().set( new Date() );
+        statePrototype.creationDate().set( Instant.now() );
         return builder.newInstance();
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
----------------------------------------------------------------------
diff --git a/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java b/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
index 0cbb157..34fc11c 100644
--- a/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
+++ b/libraries/appbrowser/src/test/java/org/apache/zest/library/appbrowser/AppBrowserTest.java
@@ -20,7 +20,6 @@ package org.apache.zest.library.appbrowser;
 
 import java.io.StringWriter;
 import java.io.Writer;
-import org.joda.time.DateTime;
 import org.junit.Test;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
index befc099..abe761a 100644
--- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
+++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/CircuitBreaker.java
@@ -24,7 +24,7 @@ import java.beans.PropertyChangeSupport;
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 import java.beans.VetoableChangeSupport;
-import java.util.Date;
+import java.time.Instant;
 import java.util.function.Predicate;
 
 /**
@@ -43,8 +43,8 @@ public class CircuitBreaker
     private Predicate<Throwable> allowedThrowables;
 
     private int countDown;
-    private long trippedOn = -1;
-    private long enableOn = -1;
+    private Instant trippedOn;
+    private Instant enableOn;
 
     private Status status = Status.on;
 
@@ -86,8 +86,8 @@ public class CircuitBreaker
             status = Status.off;
             pcs.firePropertyChange( "status", Status.on, Status.off );
 
-            trippedOn = System.currentTimeMillis();
-            enableOn = trippedOn + timeout;
+            trippedOn = Instant.now();
+            enableOn = trippedOn.plusMillis( timeout );
         }
     }
 
@@ -101,8 +101,8 @@ public class CircuitBreaker
                 vcs.fireVetoableChange( "status", Status.off, Status.on );
                 status = Status.on;
                 countDown = threshold;
-                trippedOn = -1;
-                enableOn = -1;
+                trippedOn = null;
+                enableOn = null;
                 lastThrowable = null;
 
                 pcs.firePropertyChange( "status", Status.off, Status.on );
@@ -110,7 +110,7 @@ public class CircuitBreaker
             catch( PropertyVetoException e )
             {
                 // Reset timeout
-                enableOn = System.currentTimeMillis() + timeout;
+                enableOn = Instant.now().plusMillis( timeout );
 
                 if( e.getCause() != null )
                 {
@@ -144,7 +144,7 @@ public class CircuitBreaker
     {
         if( status == Status.off )
         {
-            if( System.currentTimeMillis() > enableOn )
+            if( Instant.now().isAfter( enableOn ) )
             {
                 try
                 {
@@ -167,14 +167,14 @@ public class CircuitBreaker
         return status;
     }
 
-    public Date trippedOn()
+    public Instant trippedOn()
     {
-        return trippedOn == -1 ? null : new Date( trippedOn );
+        return trippedOn;
     }
 
-    public Date enabledOn()
+    public Instant enabledOn()
     {
-        return enableOn == -1 ? null : new Date( enableOn );
+        return enableOn;
     }
 
     public boolean isOn()

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
----------------------------------------------------------------------
diff --git a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
index 8fabe2a..32d7473 100644
--- a/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
+++ b/libraries/circuitbreaker/src/main/java/org/apache/zest/library/circuitbreaker/jmx/CircuitBreakerJMX.java
@@ -23,8 +23,7 @@ package org.apache.zest.library.circuitbreaker.jmx;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyVetoException;
-import java.text.DateFormat;
-import java.util.Date;
+import java.time.Instant;
 import javax.management.MBeanNotificationInfo;
 import javax.management.Notification;
 import javax.management.NotificationBroadcasterSupport;
@@ -98,15 +97,15 @@ public class CircuitBreakerJMX
    @Override
    public String getTrippedOn()
    {
-      Date trippedOn = circuitBreaker.trippedOn();
-      return trippedOn == null ? "" : DateFormat.getDateTimeInstance().format(trippedOn);
+      Instant trippedOn = circuitBreaker.trippedOn();
+      return trippedOn == null ? "" : trippedOn.toString();
    }
 
    @Override
    public String getEnableOn()
    {
-      Date trippedOn = circuitBreaker.enabledOn();
-      return trippedOn == null ? "" : DateFormat.getDateTimeInstance().format(trippedOn);
+      Instant trippedOn = circuitBreaker.enabledOn();
+      return trippedOn == null ? "" : trippedOn.toString();
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
index 53e5c14..13c1868 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/EntityToValueTest.java
@@ -19,7 +19,8 @@
  */
 package org.apache.zest.library.conversion.values;
 
-import java.util.Date;
+import java.time.Instant;
+import java.time.LocalDate;
 import java.util.function.Function;
 import org.junit.Test;
 import org.apache.zest.api.constraint.ConstraintViolationException;
@@ -209,7 +210,7 @@ public class EntityToValueTest
     {
         String firstName = "Niclas";
         String lastName = "Hedhman";
-        Date birthTime = createBirthDate( 1964, 9, 25 );
+        LocalDate birthTime = createBirthDate( 1964, 9, 25 );
         return createPerson( uow, firstName, lastName, birthTime );
     }
 
@@ -217,7 +218,7 @@ public class EntityToValueTest
     {
         String firstName = "Lis";
         String lastName = "Gazi";
-        Date birthTime = createBirthDate( 1976, 2, 19 );
+        LocalDate birthTime = createBirthDate( 1976, 2, 19 );
         return createPerson( uow, firstName, lastName, birthTime );
     }
 
@@ -225,7 +226,7 @@ public class EntityToValueTest
     {
         String firstName = "Eric";
         String lastName = "Hedman";
-        Date birthTime = createBirthDate( 2004, 4, 8 );
+        LocalDate birthTime = createBirthDate( 2004, 4, 8 );
         return createPerson( uow, firstName, lastName, birthTime );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
index 1a1ec60..54fe910 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/TestModel.java
@@ -19,10 +19,12 @@
  */
 package org.apache.zest.library.conversion.values;
 
-import java.util.Calendar;
-import java.util.Date;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.List;
-import java.util.TimeZone;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.Optional;
@@ -34,27 +36,26 @@ import org.apache.zest.api.property.Property;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.value.ValueComposite;
 
+import static java.time.ZoneOffset.UTC;
+
 /**
  * Test Model.
  */
 final class TestModel
 {
-    static PersonEntity createPerson( UnitOfWork uow, String firstName, String lastName, Date birthTime )
+    static PersonEntity createPerson( UnitOfWork uow, String firstName, String lastName, LocalDate birthDate )
     {
         EntityBuilder<PersonEntity> builder = uow.newEntityBuilder( PersonEntity.class, "id:" + firstName );
         PersonState state = builder.instanceFor( PersonState.class );
         state.firstName().set( firstName );
         state.lastName().set( lastName );
-        state.dateOfBirth().set( birthTime );
+        state.dateOfBirth().set( birthDate );
         return builder.newInstance();
     }
 
-    static Date createBirthDate( int year, int month, int day )
+    static LocalDate createBirthDate( int year, int month, int day )
     {
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
-        calendar.set( year, month - 1, day, 12, 0, 0 );
-        return calendar.getTime();
+        return LocalDate.of( year, month, day);
     }
 
     // START SNIPPET: state
@@ -65,7 +66,7 @@ final class TestModel
 
         Property<String> lastName();
 
-        Property<Date> dateOfBirth();
+        Property<LocalDate> dateOfBirth();
 
     }
     // END SNIPPET: state
@@ -128,9 +129,8 @@ final class TestModel
         @Override
         public Integer age()
         {
-            long now = System.currentTimeMillis();
-            long birthdate = state.dateOfBirth().get().getTime();
-            return (int) ( ( now - birthdate ) / 1000 / 3600 / 24 / 365.25 );
+            Duration age = Duration.between( state.dateOfBirth().get(), Instant.now() );
+            return (int) age.toDays()/365;
         }
 
         // START SNIPPET: entity
@@ -147,7 +147,7 @@ final class TestModel
 
         Property<String> lastName();
 
-        Property<Date> dateOfBirth();
+        Property<LocalDate> dateOfBirth();
 
         @Optional
         Property<String> spouse();
@@ -167,7 +167,7 @@ final class TestModel
 
         Property<String> lastName();
 
-        Property<Date> dateOfBirth();
+        Property<LocalDate> dateOfBirth();
 
         @Optional
         Property<String> spouse();
@@ -186,7 +186,7 @@ final class TestModel
 
         Property<String> lastName();
 
-        Property<Date> dateOfBirth();
+        Property<LocalDate> dateOfBirth();
 
         @Optional
         Property<String> spouse();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
----------------------------------------------------------------------
diff --git a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
index d88f33f..c0f8eea 100644
--- a/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
+++ b/libraries/conversion/src/test/java/org/apache/zest/library/conversion/values/ValueToEntityTest.java
@@ -19,8 +19,8 @@
  */
 package org.apache.zest.library.conversion.values;
 
+import java.time.LocalDate;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.function.Predicate;
 import org.junit.Before;
 import org.junit.Test;
@@ -69,7 +69,7 @@ public class ValueToEntityTest
         module.values( PersonValue4.class );
     }
 
-    private Date someBirthDate;
+    private LocalDate someBirthDate;
     private String ednaIdentity;
     private String zekeIdentity;
     private String fredIdentity;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java b/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
index 7098e83..cdd435e 100644
--- a/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
+++ b/libraries/eventsourcing-rest/src/main/java/org/apache/zest/library/eventsourcing/domain/rest/server/DomainEventSourceResource.java
@@ -23,7 +23,6 @@ package org.apache.zest.library.eventsourcing.domain.rest.server;
 import java.io.IOException;
 import java.io.Writer;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.service.qualifier.Tagged;
@@ -38,11 +37,17 @@ import org.restlet.data.CharacterSet;
 import org.restlet.data.MediaType;
 import org.restlet.data.Reference;
 import org.restlet.data.Status;
-import org.restlet.ext.atom.*;
+import org.restlet.ext.atom.Content;
+import org.restlet.ext.atom.Entry;
+import org.restlet.ext.atom.Feed;
+import org.restlet.ext.atom.Link;
+import org.restlet.ext.atom.Relation;
+import org.restlet.ext.atom.Text;
 import org.restlet.representation.StringRepresentation;
 import org.restlet.representation.WriterRepresentation;
 import org.restlet.resource.ResourceException;
 
+import static java.util.Date.from;
 import static org.apache.zest.functional.Iterables.iterable;
 
 /**
@@ -187,13 +192,14 @@ public class DomainEventSourceResource
         }
 */
 
-        Date lastModified = null;
+        java.util.Date lastModified = null;
         for (UnitOfWorkDomainEventsValue eventsValue : eventsValues)
         {
             Entry entry = new Entry();
             entry.setTitle( new Text( eventsValue.usecase().get() + "(" + eventsValue.user().get() + ")" ) );
-            entry.setPublished( new Date( eventsValue.timestamp().get() ) );
-            entry.setModificationDate( lastModified = new Date( eventsValue.timestamp().get() ) );
+            entry.setPublished( from( eventsValue.timestamp().get() ) );
+            lastModified = from( eventsValue.timestamp().get() );
+            entry.setModificationDate( lastModified );
             entry.setId( Long.toString( startEvent + 1 ) );
             startEvent++;
             Content content = new Content();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
index 6aabfb2..979761a 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/api/ApplicationEvent.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.eventsourcing.application.api;
 
-import java.util.Date;
+import java.time.Instant;
 import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.value.ValueComposite;
@@ -50,7 +50,7 @@ public interface ApplicationEvent
     Property<String> name();
 
     // When the event was created
-    Property<Date> on();
+    Property<Instant> on();
 
     // Method parameters as JSON
     Property<String> parameters();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
index 183af70..ae83019 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/factory/ApplicationEventFactoryService.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.library.eventsourcing.application.factory;
 
+import java.time.Instant;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONStringer;
@@ -38,8 +39,6 @@ import org.apache.zest.api.value.ValueBuilderFactory;
 import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
 import org.apache.zest.library.eventsourcing.domain.spi.CurrentUser;
 
-import java.util.Date;
-
 /**
  * DomainEventValue factory
  */
@@ -77,7 +76,7 @@ public interface ApplicationEventFactoryService
 
             ApplicationEvent prototype = builder.prototype();
             prototype.name().set( name );
-            prototype.on().set( new Date() );
+            prototype.on().set( Instant.now() );
 
             prototype.identity().set( idGenerator.generate( ApplicationEvent.class ) );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
index 8a8e1ce..cca1d01 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/replay/ApplicationEventPlayerService.java
@@ -22,10 +22,8 @@ package org.apache.zest.library.eventsourcing.application.replay;
 
 import java.lang.reflect.Method;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
 import org.apache.zest.api.ZestAPI;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.mixin.Mixins;
@@ -35,6 +33,8 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.value.ValueComposite;
 import org.apache.zest.library.eventsourcing.application.api.ApplicationEvent;
+import org.json.JSONObject;
+import org.json.JSONTokener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,7 +58,7 @@ public interface ApplicationEventPlayerService
         @Structure
         ZestAPI api;
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy" );
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
 
         @Override
         public void playEvent( ApplicationEvent applicationEvent, Object object )
@@ -122,7 +122,7 @@ public interface ApplicationEventPlayerService
             } else if (parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ))
             {
                 return ((Number) value).intValue();
-            } else if (parameterType.equals( Date.class ))
+            } else if (parameterType.equals( Instant.class ))
             {
                 return dateFormat.parse( (String) value );
             } else if (ValueComposite.class.isAssignableFrom( parameterType ))

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
index 7c79395..edd5c8f 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/application/source/helper/ApplicationEvents.java
@@ -21,10 +21,9 @@
 package org.apache.zest.library.eventsourcing.application.source.helper;
 
 import java.lang.reflect.Method;
+import java.time.Instant;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
-import java.util.function.Function;
 import java.util.function.Predicate;
 import org.apache.zest.api.util.Methods;
 import org.apache.zest.functional.Iterables;
@@ -43,14 +42,14 @@ public class ApplicationEvents
 {
     public static Iterable<ApplicationEvent> events( Iterable<TransactionApplicationEvents> transactions )
     {
-        List<Iterable<ApplicationEvent>> events = new ArrayList<Iterable<ApplicationEvent>>();
+        List<Iterable<ApplicationEvent>> events = new ArrayList<>();
         for (TransactionApplicationEvents transactionDomain : transactions)
         {
             events.add( transactionDomain.events().get() );
         }
 
         Iterable<ApplicationEvent>[] iterables = (Iterable<ApplicationEvent>[]) new Iterable[events.size()];
-        return Iterables.flatten( events.<Iterable<ApplicationEvent>>toArray( iterables ) );
+        return Iterables.flatten( events.toArray( iterables ) );
     }
 
     public static Iterable<ApplicationEvent> events( TransactionApplicationEvents... transactionDomains )
@@ -120,57 +119,31 @@ public class ApplicationEvents
 //        }, Iterables.toList( Methods.METHODS_OF.apply( eventClass ) ) ));
     }
 
-    public static Predicate<ApplicationEvent> afterDate( final Date afterDate )
+    public static Predicate<ApplicationEvent> afterDate( final Instant afterDate )
     {
-        return new Predicate<ApplicationEvent>()
-        {
-            @Override
-            public boolean test( ApplicationEvent event )
-            {
-                return event.on().get().after( afterDate );
-            }
-        };
+        return event -> event.on().get().isAfter( afterDate );
     }
 
-    public static Predicate<ApplicationEvent> beforeDate( final Date beforeDate )
+    public static Predicate<ApplicationEvent> beforeDate( final Instant beforeDate )
     {
-        return new Predicate<ApplicationEvent>()
-        {
-            @Override
-            public boolean test( ApplicationEvent event )
-            {
-                return event.on().get().before( beforeDate );
-            }
-        };
+        return event -> event.on().get().isBefore( beforeDate );
     }
 
     public static Predicate<ApplicationEvent> withUsecases( final String... names )
     {
-        return new Predicate<ApplicationEvent>()
-        {
-            @Override
-            public boolean test( ApplicationEvent event )
+        return event -> {
+            for (String name : names)
             {
-                for (String name : names)
-                {
-                    if (event.usecase().get().equals( name ))
-                        return true;
-                }
-                return false;
+                if (event.usecase().get().equals( name ))
+                    return true;
             }
+            return false;
         };
     }
 
     public static Predicate<ApplicationEvent> paramIs( final String name, final String value )
     {
-        return new Predicate<ApplicationEvent>()
-        {
-            @Override
-            public boolean test( ApplicationEvent event )
-            {
-                return ApplicationEventParameters.getParameter( event, name ).equals( value );
-            }
-        };
+        return event -> ApplicationEventParameters.getParameter( event, name ).equals( value );
     }
 
     public static Output<TransactionApplicationEvents, ApplicationEventReplayException> playEvents( final ApplicationEventPlayer player, final Object eventHandler )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
index 72aa6b3..4cec265 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/api/UnitOfWorkDomainEventsValue.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.library.eventsourcing.domain.api;
 
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.common.UseDefaults;
@@ -44,7 +45,7 @@ public interface UnitOfWorkDomainEventsValue
     Property<String> usecase();
 
     // When the event occurred
-    Property<Long> timestamp();
+    Property<Instant> timestamp();
 
     // Who performed the event. Taken from CurrentUser service.
     @Optional

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
index f4b4f5f..7ac8f2a 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/factory/UnitOfWorkNotificationConcern.java
@@ -21,6 +21,7 @@
 package org.apache.zest.library.eventsourcing.domain.factory;
 
 import java.io.IOException;
+import java.time.Instant;
 import org.apache.zest.api.ZestAPI;
 import org.apache.zest.api.concern.ConcernOf;
 import org.apache.zest.api.entity.EntityComposite;
@@ -114,7 +115,7 @@ public class UnitOfWorkNotificationConcern
 
                         ValueBuilder<UnitOfWorkDomainEventsValue> builder = vbf.newValueBuilder( UnitOfWorkDomainEventsValue.class );
                         builder.prototype().user().set( user );
-                        builder.prototype().timestamp().set( System.currentTimeMillis() );
+                        builder.prototype().timestamp().set( Instant.now() );
                         builder.prototype().usecase().set( unitOfWork.usecase().name() );
                         builder.prototype().version().set( version );
                         builder.prototype().events().get().addAll( events.getEventValues() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
index 79d017b..890fea9 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/replay/DomainEventPlayerService.java
@@ -22,10 +22,8 @@ package org.apache.zest.library.eventsourcing.domain.replay;
 
 import java.lang.reflect.Method;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.mixin.Mixins;
@@ -40,18 +38,20 @@ import org.apache.zest.library.eventsourcing.domain.api.DomainEventValue;
 import org.apache.zest.library.eventsourcing.domain.api.UnitOfWorkDomainEventsValue;
 import org.apache.zest.spi.ZestSPI;
 import org.apache.zest.spi.entity.EntityState;
+import org.json.JSONObject;
+import org.json.JSONTokener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * DomainEventValue player
  */
-@Mixins(DomainEventPlayerService.Mixin.class)
+@Mixins( DomainEventPlayerService.Mixin.class )
 public interface DomainEventPlayerService
-        extends DomainEventPlayer, ServiceComposite
+    extends DomainEventPlayer, ServiceComposite
 {
     class Mixin
-            implements DomainEventPlayer
+        implements DomainEventPlayer
     {
         final Logger logger = LoggerFactory.getLogger( DomainEventPlayer.class );
 
@@ -64,27 +64,30 @@ public interface DomainEventPlayerService
         @Structure
         ZestSPI spi;
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss zzz yyyy" );
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern( "EEE MMM dd HH:mm:ss zzz yyyy" );
 
         @Override
         public void playTransaction( UnitOfWorkDomainEventsValue unitOfWorkDomainValue )
-                throws EventReplayException
+            throws EventReplayException
         {
             UnitOfWork uow = uowf.newUnitOfWork( UsecaseBuilder.newUsecase( "Event replay" ) );
             DomainEventValue currentEventValue = null;
             try
             {
-                for (DomainEventValue domainEventValue : unitOfWorkDomainValue.events().get())
+                for( DomainEventValue domainEventValue : unitOfWorkDomainValue.events().get() )
                 {
                     currentEventValue = domainEventValue;
                     // Get the entity
-                    Class entityType = module.descriptor().classLoader().loadClass( domainEventValue.entityType().get() );
+                    Class entityType = module.descriptor()
+                        .classLoader()
+                        .loadClass( domainEventValue.entityType().get() );
                     String id = domainEventValue.entityId().get();
                     Object entity = null;
                     try
                     {
                         entity = uow.get( entityType, id );
-                    } catch( NoSuchEntityException e )
+                    }
+                    catch( NoSuchEntityException e )
                     {
                         // Event to play for an entity that doesn't yet exist - create a default instance
                         entity = uow.newEntity( entityType, id );
@@ -92,7 +95,7 @@ public interface DomainEventPlayerService
 
                     // check if the event has already occured
                     EntityState state = spi.entityStateOf( (EntityComposite) entity );
-                    if (state.lastModified() > unitOfWorkDomainValue.timestamp().get())
+                    if( state.lastModified() > unitOfWorkDomainValue.timestamp().get().toEpochMilli() )
                     {
                         break; // don't rerun event in this unitOfWorkDomainValue
                     }
@@ -100,19 +103,24 @@ public interface DomainEventPlayerService
                     playEvent( domainEventValue, entity );
                 }
                 uow.complete();
-            } catch (Exception e)
+            }
+            catch( Exception e )
             {
                 uow.discard();
-                if (e instanceof EventReplayException)
-                    throw ((EventReplayException) e);
+                if( e instanceof EventReplayException )
+                {
+                    throw ( (EventReplayException) e );
+                }
                 else
+                {
                     throw new EventReplayException( currentEventValue, e );
+                }
             }
         }
 
         @Override
         public void playEvent( DomainEventValue domainEventValue, Object object )
-                throws EventReplayException
+            throws EventReplayException
         {
             UnitOfWork uow = uowf.currentUnitOfWork();
             Class entityType = object.getClass();
@@ -120,9 +128,10 @@ public interface DomainEventPlayerService
             // Get method
             Method eventMethod = getEventMethod( entityType, domainEventValue.name().get() );
 
-            if (eventMethod == null)
+            if( eventMethod == null )
             {
-                logger.warn( "Could not find event method " + domainEventValue.name().get() + " in entity of type " + entityType.getName() );
+                logger.warn( "Could not find event method " + domainEventValue.name()
+                    .get() + " in entity of type " + entityType.getName() );
                 return;
             }
 
@@ -131,60 +140,68 @@ public interface DomainEventPlayerService
             {
                 String jsonParameters = domainEventValue.parameters().get();
                 JSONObject parameters = (JSONObject) new JSONTokener( jsonParameters ).nextValue();
-                Object[] args = new Object[eventMethod.getParameterTypes().length];
-                for (int i = 1; i < eventMethod.getParameterTypes().length; i++)
+                Object[] args = new Object[ eventMethod.getParameterTypes().length ];
+                for( int i = 1; i < eventMethod.getParameterTypes().length; i++ )
                 {
-                    Class<?> parameterType = eventMethod.getParameterTypes()[i];
-
+                    Class<?> parameterType = eventMethod.getParameterTypes()[ i ];
                     String paramName = "param" + i;
-
                     Object value = parameters.get( paramName );
-
-                    args[i] = getParameterArgument( parameterType, value, uow );
+                    args[ i ] = getParameterArgument( parameterType, value, uow );
                 }
-
-                args[0] = domainEventValue;
+                args[ 0 ] = domainEventValue;
 
                 // Invoke method
                 logger.debug( "Replay:" + domainEventValue + " on:" + object );
 
                 eventMethod.invoke( object, args );
-            } catch (Exception e)
+            }
+            catch( Exception e )
             {
                 throw new EventReplayException( domainEventValue, e );
             }
         }
 
-        private Object getParameterArgument( Class<?> parameterType, Object value, UnitOfWork uow ) throws ParseException
+        private Object getParameterArgument( Class<?> parameterType, Object value, UnitOfWork uow )
+            throws ParseException
         {
-            if (value.equals( JSONObject.NULL ))
+            if( value.equals( JSONObject.NULL ) )
+            {
                 return null;
+            }
 
-            if (parameterType.equals( String.class ))
+            if( parameterType.equals( String.class ) )
             {
                 return (String) value;
-            } else if (parameterType.equals( Boolean.class ) || parameterType.equals( Boolean.TYPE ))
+            }
+            else if( parameterType.equals( Boolean.class ) || parameterType.equals( Boolean.TYPE ) )
             {
                 return (Boolean) value;
-            } else if (parameterType.equals( Long.class ) || parameterType.equals( Long.TYPE ))
+            }
+            else if( parameterType.equals( Long.class ) || parameterType.equals( Long.TYPE ) )
             {
-                return ((Number) value).longValue();
-            } else if (parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ))
+                return ( (Number) value ).longValue();
+            }
+            else if( parameterType.equals( Integer.class ) || parameterType.equals( Integer.TYPE ) )
             {
-                return ((Number) value).intValue();
-            } else if (parameterType.equals( Date.class ))
+                return ( (Number) value ).intValue();
+            }
+            else if( parameterType.equals( Instant.class ) )
             {
                 return dateFormat.parse( (String) value );
-            } else if (ValueComposite.class.isAssignableFrom( parameterType ))
+            }
+            else if( ValueComposite.class.isAssignableFrom( parameterType ) )
             {
                 return module.newValueFromSerializedState( parameterType, (String) value );
-            } else if (parameterType.isInterface())
+            }
+            else if( parameterType.isInterface() )
             {
                 return uow.get( parameterType, (String) value );
-            } else if (parameterType.isEnum())
+            }
+            else if( parameterType.isEnum() )
             {
                 return Enum.valueOf( (Class<? extends Enum>) parameterType, value.toString() );
-            } else
+            }
+            else
             {
                 throw new IllegalArgumentException( "Unknown parameter type:" + parameterType.getName() );
             }
@@ -192,13 +209,15 @@ public interface DomainEventPlayerService
 
         private Method getEventMethod( Class<?> aClass, String eventName )
         {
-            for (Method method : aClass.getMethods())
+            for( Method method : aClass.getMethods() )
             {
-                if (method.getName().equals( eventName ))
+                if( method.getName().equals( eventName ) )
                 {
                     Class[] parameterTypes = method.getParameterTypes();
-                    if (parameterTypes.length > 0 && parameterTypes[0].equals( DomainEventValue.class ))
+                    if( parameterTypes.length > 0 && parameterTypes[ 0 ].equals( DomainEventValue.class ) )
+                    {
                         return method;
+                    }
                 }
             }
             return null;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
index 42cd9d1..6662621 100644
--- a/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
+++ b/libraries/eventsourcing/src/main/java/org/apache/zest/library/eventsourcing/domain/source/helper/Events.java
@@ -21,7 +21,6 @@
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
 import java.lang.reflect.Method;
-import java.util.Date;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import org.apache.zest.api.util.Methods;
@@ -51,17 +50,6 @@ public class Events
         return events( Iterables.iterable( unitOfWorkDomainValues ) );
     }
 
-    // Common specifications
-    public static Predicate<UnitOfWorkDomainEventsValue> afterDate( final Date afterDate )
-    {
-        return eventValue -> eventValue.timestamp().get() > afterDate.getTime();
-    }
-
-    public static Predicate<UnitOfWorkDomainEventsValue> beforeDate( final Date afterDate )
-    {
-        return eventValue -> eventValue.timestamp().get() < afterDate.getTime();
-    }
-
     public static Predicate<UnitOfWorkDomainEventsValue> withUsecases( final String... names )
     {
         return eventValue -> {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
index 6610af4..e85b5a4 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventRouterTest.java
@@ -20,6 +20,7 @@
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
 import java.io.IOException;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
@@ -67,7 +68,7 @@ public class EventRouterTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ) );
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ) );
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test" );
             list.add( builder.newInstance() );
         }
@@ -77,7 +78,7 @@ public class EventRouterTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ) );
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ) );
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test2" );
             list.add( builder.newInstance() );
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
index eed1376..a466f83 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/EventsTest.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
+import java.time.Instant;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
 import org.junit.Before;
@@ -70,7 +71,7 @@ public class EventsTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ) );
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ) );
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test" );
             list.add( builder.newInstance() );
         }
@@ -80,7 +81,7 @@ public class EventsTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ) );
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ) );
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test2" );
             list.add( builder.newInstance() );
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
----------------------------------------------------------------------
diff --git a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
index 76d66a6..2ade4ce 100644
--- a/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
+++ b/libraries/eventsourcing/src/test/java/org/apache/zest/library/eventsourcing/domain/source/helper/UnitOfWorkRouterTest.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.eventsourcing.domain.source.helper;
 
+import java.time.Instant;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
 import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
 import org.hamcrest.CoreMatchers;
@@ -68,7 +69,7 @@ public class UnitOfWorkRouterTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test2" ));
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test3" ));
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test" );
             list.add( builder.newInstance() );
         }
@@ -78,7 +79,7 @@ public class UnitOfWorkRouterTest
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test5" ));
             builder.prototype().events().get().add( newDomainEvent( assembler, "Test6" ));
             builder.prototype().version().set( "1.0" );
-            builder.prototype().timestamp().set( System.currentTimeMillis() );
+            builder.prototype().timestamp().set( Instant.now() );
             builder.prototype().usecase().set( "Test2" );
             list.add( builder.newInstance() );
         }


Mime
View raw message