polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [7/7] zest-java git commit: ZEST-181 : Replaced the use of 'long' as a time and using java.time.Instant instead.
Date Sat, 22 Oct 2016 07:18:52 GMT
ZEST-181 : Replaced the use of 'long' as a time and using java.time.Instant instead.


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/e030bd8a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/e030bd8a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/e030bd8a

Branch: refs/heads/develop
Commit: e030bd8a586efb272ad030a4762e18b24feee4c0
Parents: f37a0a0
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Sat Oct 22 15:14:38 2016 +0800
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Sat Oct 22 15:14:38 2016 +0800

----------------------------------------------------------------------
 .../zest/api/activation/ActivationEvent.java    |  7 ++-
 .../org/apache/zest/api/time/SystemTime.java    | 24 ++++++++++
 .../apache/zest/api/unitofwork/UnitOfWork.java  |  3 +-
 .../zest/api/unitofwork/UnitOfWorkFactory.java  | 10 ++--
 .../runtime/unitofwork/BuilderEntityState.java  |  5 +-
 .../runtime/unitofwork/ModuleUnitOfWork.java    |  3 +-
 .../unitofwork/UnitOfWorkFactoryMixin.java      |  8 ++--
 .../runtime/unitofwork/UnitOfWorkInstance.java  |  7 +--
 .../org/apache/zest/api/common/PluginTest.java  |  6 ++-
 .../org/apache/zest/spi/entity/EntityState.java |  5 +-
 .../ConcurrentModificationCheckConcern.java     |  9 ++--
 .../DefaultEntityStoreUnitOfWork.java           |  7 +--
 .../spi/entitystore/EntityStateVersions.java    |  7 ++-
 .../zest/spi/entitystore/EntityStore.java       |  3 +-
 .../spi/entitystore/EntityStoreUnitOfWork.java  |  3 +-
 .../entitystore/helpers/DefaultEntityState.java |  9 ++--
 .../entitystore/helpers/JSONEntityState.java    |  7 +--
 .../zest/spi/entitystore/helpers/JSONKeys.java  |  4 +-
 .../helpers/JSONMapEntityStoreMixin.java        | 16 ++++---
 .../helpers/MapEntityStoreMixin.java            |  9 ++--
 .../helpers/JSONManyAssociationStateTest.java   |  5 +-
 .../zest/spi/metrics/DefaultMetricsTest.java    |  8 ++--
 .../jclouds/JCloudsFilesystemTest.java          |  3 +-
 .../prefs/PreferencesEntityStoreMixin.java      | 14 +++---
 .../entitystore/sql/SQLEntityStoreMixin.java    |  7 +--
 .../sql/internal/DatabaseSQLService.java        |  5 +-
 .../DatabaseSQLServiceStatementsMixin.java      |  9 ++--
 .../sql/internal/SQLEntityState.java            |  9 ++--
 .../elasticsearch/ElasticSearchIndexer.java     |  6 ++-
 .../zest/index/rdf/RDFPerformanceTest.java      | 50 ++++++++++----------
 .../solr/internal/SolrEntityIndexerMixin.java   |  2 +-
 .../support/skeletons/AbstractSQLIndexing.java  |  4 +-
 .../skeletons/SQLCompatEntityStateWrapper.java  |  5 +-
 .../circuitbreaker/jmx/CircuitBreakerJMX.java   |  6 ++-
 .../fileconfig/FileConfigurationTest.java       |  2 +-
 .../logging/debug/records/DebugRecord.java      |  3 +-
 .../debug/service/DebuggingServiceMixin.java    |  3 +-
 .../library/logging/log/records/LogRecord.java  |  3 +-
 .../log/service/LoggingServiceMixin.java        |  3 +-
 .../logging/trace/AbstractTraceConcern.java     | 15 +++---
 .../logging/trace/TraceOnConsoleSideEffect.java | 14 +++---
 .../logging/trace/records/TraceRecord.java      |  6 ++-
 .../logging/trace/service/TraceService.java     |  6 ++-
 .../trace/service/TraceServiceMixin.java        | 30 ++++++------
 .../rdf/entity/EntitySerializerTest.java        |  4 +-
 .../rest/server/api/ResourceValidity.java       | 14 ++----
 .../zest/library/rest/admin/EntityResource.java | 14 +++---
 .../sample/forum/context/view/ViewPost.java     |  2 +-
 .../forum/domainevent/DomainEventValue.java     |  3 +-
 .../CompositeCreationPerformanceTest.java       |  3 ++
 50 files changed, 241 insertions(+), 169 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java b/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
index 3af6c93..553ede4 100644
--- a/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
+++ b/core/api/src/main/java/org/apache/zest/api/activation/ActivationEvent.java
@@ -19,6 +19,9 @@
  */
 package org.apache.zest.api.activation;
 
+import java.time.Instant;
+import org.apache.zest.api.time.SystemTime;
+
 /**
  * ActivationEvents are fired during activation and passivation of instances in Zest.
  */
@@ -29,13 +32,13 @@ public final class ActivationEvent
         ACTIVATING, ACTIVATED, PASSIVATING, PASSIVATED
     }
 
-    private final long timestamp;
+    private final Instant timestamp;
     private final Object source;
     private final EventType type;
 
     public ActivationEvent( Object source, EventType type )
     {
-        this.timestamp = System.currentTimeMillis();
+        this.timestamp = SystemTime.now();
         this.source = source;
         this.type = type;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/api/src/main/java/org/apache/zest/api/time/SystemTime.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/time/SystemTime.java b/core/api/src/main/java/org/apache/zest/api/time/SystemTime.java
new file mode 100644
index 0000000..4601551
--- /dev/null
+++ b/core/api/src/main/java/org/apache/zest/api/time/SystemTime.java
@@ -0,0 +1,24 @@
+package org.apache.zest.api.time;
+
+import java.time.Clock;
+import java.time.Instant;
+
+public class SystemTime
+{
+    private static Clock defaultClock = Clock.systemUTC();
+
+    public static Clock getDefaultClock()
+    {
+        return defaultClock;
+    }
+
+    public static void setDefaultClock(Clock defaultClock)
+    {
+        SystemTime.defaultClock = defaultClock;
+    }
+
+    public static Instant now()
+    {
+        return Instant.now(defaultClock);
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
index 309ca58..e792b8b 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWork.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.api.unitofwork;
 
+import java.time.Instant;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -104,7 +105,7 @@ public interface UnitOfWork extends MetaInfoHolder, AutoCloseable
      */
     UnitOfWorkFactory unitOfWorkFactory();
 
-    long currentTime();
+    Instant currentTime();
 
     /**
      * Get the Usecase for this UnitOfWork

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
index 3a80115..3a1b00e 100644
--- a/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
+++ b/core/api/src/main/java/org/apache/zest/api/unitofwork/UnitOfWorkFactory.java
@@ -19,7 +19,9 @@
  */
 package org.apache.zest.api.unitofwork;
 
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityComposite;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.usecase.Usecase;
 
 /**
@@ -33,7 +35,7 @@ public interface UnitOfWorkFactory
      * The UnitOfWork will use the default Usecase settings.
      * </p>
      * <p>
-     * Current time will be set to System.currentTimeMillis();
+     * Current time will be set to {@link SystemTime#now()}
      * </p>
      * @return a new UnitOfWork
      */
@@ -46,12 +48,12 @@ public interface UnitOfWorkFactory
      * </p>
      * @return a new UnitOfWork
      */
-    UnitOfWork newUnitOfWork( long currentTime );
+    UnitOfWork newUnitOfWork( Instant currentTime );
 
     /**
      * Create a new UnitOfWork for the given Usecase and associate it with the current thread.
      * <p>
-     * Current time will be set to System.currentTimeMillis();
+     * Current time will be set to {@link SystemTime#now()}
      * </p>
      * @param usecase the Usecase for this UnitOfWork
      *
@@ -66,7 +68,7 @@ public interface UnitOfWorkFactory
      *
      * @return a new UnitOfWork
      */
-    UnitOfWork newUnitOfWork( Usecase usecase, long currentTime );
+    UnitOfWork newUnitOfWork( Usecase usecase, Instant currentTime );
 
     /**
      * @return true if there is an active UnitOfWork associated with the executing thread

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
index 23ddf0c..6591c4c 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/BuilderEntityState.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.runtime.unitofwork;
 
+import java.time.Instant;
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.zest.api.common.QualifiedName;
@@ -62,9 +63,9 @@ public final class BuilderEntityState
     }
 
     @Override
-    public long lastModified()
+    public Instant lastModified()
     {
-        return 0;
+        return Instant.MIN;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
index d9a2d8a..222d959 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/ModuleUnitOfWork.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.runtime.unitofwork;
 
+import java.time.Instant;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -136,7 +137,7 @@ public class ModuleUnitOfWork
     }
 
     @Override
-    public long currentTime()
+    public Instant currentTime()
     {
         return uow.currentTime();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
index 828807f..b3a32fb 100644
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkFactoryMixin.java
@@ -20,11 +20,13 @@
 
 package org.apache.zest.runtime.unitofwork;
 
+import java.time.Instant;
 import java.util.Stack;
 import org.apache.zest.api.composite.TransientBuilderFactory;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.metrics.MetricsProvider;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.usecase.Usecase;
@@ -48,7 +50,7 @@ public class UnitOfWorkFactoryMixin
     }
 
     @Override
-    public UnitOfWork newUnitOfWork( long currentTime )
+    public UnitOfWork newUnitOfWork(Instant currentTime )
     {
         return newUnitOfWork( Usecase.DEFAULT, currentTime );
     }
@@ -56,11 +58,11 @@ public class UnitOfWorkFactoryMixin
     @Override
     public UnitOfWork newUnitOfWork( Usecase usecase )
     {
-        return newUnitOfWork( usecase == null ? Usecase.DEFAULT : usecase, System.currentTimeMillis() );
+        return newUnitOfWork( usecase == null ? Usecase.DEFAULT : usecase, SystemTime.now() );
     }
 
     @Override
-    public UnitOfWork newUnitOfWork( Usecase usecase, long currentTime )
+    public UnitOfWork newUnitOfWork( Usecase usecase, Instant currentTime )
     {
         UnitOfWorkInstance unitOfWorkInstance = new UnitOfWorkInstance( module, usecase, currentTime, metricsProvider() );
         return tbf.newTransient( UnitOfWork.class, unitOfWorkInstance );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
index bd125df..a294244 100755
--- a/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
+++ b/core/runtime/src/main/java/org/apache/zest/runtime/unitofwork/UnitOfWorkInstance.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.runtime.unitofwork;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -82,7 +83,7 @@ public final class UnitOfWorkInstance
     private final HashMap<EntityStore, EntityStoreUnitOfWork> storeUnitOfWork = new HashMap<>();
     private final ModuleSpi module;
     private final Usecase usecase;
-    private final long currentTime;
+    private final Instant currentTime;
     private final MetricsProvider metrics;
 
     private boolean open;
@@ -92,7 +93,7 @@ public final class UnitOfWorkInstance
     private MetaInfo metaInfo;
     private List<UnitOfWorkCallback> callbacks;
 
-    public UnitOfWorkInstance( ModuleSpi module, Usecase usecase, long currentTime, MetricsProvider metrics )
+    public UnitOfWorkInstance(ModuleSpi module, Usecase usecase, Instant currentTime, MetricsProvider metrics )
     {
         this.module = module;
         this.usecase = usecase;
@@ -105,7 +106,7 @@ public final class UnitOfWorkInstance
         startCapture();
     }
 
-    public long currentTime()
+    public Instant currentTime()
     {
         return currentTime;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/runtime/src/test/java/org/apache/zest/api/common/PluginTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/zest/api/common/PluginTest.java b/core/runtime/src/test/java/org/apache/zest/api/common/PluginTest.java
index 7499c81..63c5a5d 100644
--- a/core/runtime/src/test/java/org/apache/zest/api/common/PluginTest.java
+++ b/core/runtime/src/test/java/org/apache/zest/api/common/PluginTest.java
@@ -23,6 +23,7 @@ package org.apache.zest.api.common;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.time.Instant;
 import java.util.Collections;
 import java.util.List;
 import org.apache.zest.api.injection.scope.Service;
@@ -36,6 +37,7 @@ import org.apache.zest.api.service.ServiceImporter;
 import org.apache.zest.api.service.ServiceImporterException;
 import org.apache.zest.api.service.ServiceReference;
 import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.bootstrap.ApplicationAssembler;
 import org.apache.zest.bootstrap.ApplicationAssembly;
 import org.apache.zest.bootstrap.ApplicationAssemblyFactory;
@@ -352,11 +354,11 @@ public class PluginTest
         {
             @Service
             HelloWorld helloWorld;
-            private long time;
+            private Instant time;
 
             public SimonSaysMixin()
             {
-                time = System.currentTimeMillis();
+                time = SystemTime.now();
             }
 
             public String say( String phrase, String name )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
index 95b13f2..734f5d5 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entity/EntityState.java
@@ -23,6 +23,7 @@ import java.time.Instant;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
+import org.apache.zest.api.time.SystemTime;
 
 /**
  * State holder for Entities.
@@ -52,9 +53,9 @@ public interface EntityState
      * If the underlying EntityStore does not support timestamping, then last modified
      * must always be set to the current time.
      * </p>
-     * @return last modified timestamp of the entity, as defined by System.currentTimeMillis()
+     * @return last modified timestamp of the entity, as defined by {@link SystemTime#now()}
      */
-    long lastModified();
+    Instant lastModified();
 
     /**
      * Remove the entity represented by this EntityState when the unit of work is completed.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
index e6f5be7..0729c68 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/ConcurrentModificationCheckConcern.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.spi.entitystore;
 
+import java.time.Instant;
 import java.util.HashSet;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.zest.api.ZestAPI;
@@ -53,7 +54,7 @@ public abstract class ConcurrentModificationCheckConcern
     private ZestAPI api;
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime )
     {
         final EntityStoreUnitOfWork uow = next.newUnitOfWork( module, usecase, currentTime );
         return new ConcurrentCheckingEntityStoreUnitOfWork( uow, api.dereference( versions ), currentTime );
@@ -64,7 +65,7 @@ public abstract class ConcurrentModificationCheckConcern
     {
         private final EntityStoreUnitOfWork uow;
         private EntityStateVersions versions;
-        private long currentTime;
+        private Instant currentTime;
 
         private HashSet<EntityState> loaded = new HashSet<>();
 
@@ -72,7 +73,7 @@ public abstract class ConcurrentModificationCheckConcern
 
         public ConcurrentCheckingEntityStoreUnitOfWork( EntityStoreUnitOfWork uow,
                                                         EntityStateVersions versions,
-                                                        long currentTime
+                                                        Instant currentTime
         )
         {
             this.uow = uow;
@@ -87,7 +88,7 @@ public abstract class ConcurrentModificationCheckConcern
         }
 
         @Override
-        public long currentTime()
+        public Instant currentTime()
         {
             return uow.currentTime();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
index a915465..96e4927 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/DefaultEntityStoreUnitOfWork.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.spi.entitystore;
 
+import java.time.Instant;
 import java.util.HashMap;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
@@ -38,13 +39,13 @@ public final class DefaultEntityStoreUnitOfWork
     private String identity;
     private HashMap<EntityReference, EntityState> states = new HashMap<>();
     private Usecase usecase;
-    private long currentTime;
+    private Instant currentTime;
 
     public DefaultEntityStoreUnitOfWork( ModuleDescriptor module,
                                          EntityStoreSPI entityStoreSPI,
                                          String identity,
                                          Usecase usecase,
-                                         long currentTime
+                                         Instant currentTime
     )
     {
         this.module = module;
@@ -61,7 +62,7 @@ public final class DefaultEntityStoreUnitOfWork
     }
 
     @Override
-    public long currentTime()
+    public Instant currentTime()
     {
         return currentTime;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
index 790af5e..d1913b7 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStateVersions.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.spi.entitystore;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -27,11 +28,9 @@ import java.util.WeakHashMap;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
-import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.spi.entity.EntityState;
 import org.apache.zest.spi.entity.EntityStatus;
-import org.apache.zest.spi.module.ModuleSpi;
 
 /**
  * Entity versions state.
@@ -43,7 +42,7 @@ public interface EntityStateVersions
 
     void rememberVersion( EntityReference identity, String version );
 
-    void checkForConcurrentModification( Iterable<EntityState> loaded, long currentTime )
+    void checkForConcurrentModification( Iterable<EntityState> loaded, Instant currentTime )
         throws ConcurrentEntityStateModificationException;
 
     /**
@@ -74,7 +73,7 @@ public interface EntityStateVersions
 
         @Override
         public synchronized void checkForConcurrentModification( Iterable<EntityState> loaded,
-                                                                 long currentTime
+                                                                 Instant currentTime
         )
             throws ConcurrentEntityStateModificationException
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
index 7fbc4ee..71752b0 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStore.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.spi.entitystore;
 
+import java.time.Instant;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.io.Input;
@@ -29,7 +30,7 @@ import org.apache.zest.spi.entity.EntityState;
  */
 public interface EntityStore
 {
-    EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime );
+    EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime );
 
     Input<EntityState, EntityStoreException> entityStates( ModuleDescriptor module );
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
index 712d86b..5342327 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/EntityStoreUnitOfWork.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.spi.entitystore;
 
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.structure.ModuleDescriptor;
@@ -33,7 +34,7 @@ public interface EntityStoreUnitOfWork
 {
     String identity();
 
-    long currentTime();
+    Instant currentTime();
 
     /**
      * Create new EntityState for a given identity.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
index 3375670..2827a93 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/DefaultEntityState.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.spi.entitystore.helpers;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -42,7 +43,7 @@ public final class DefaultEntityState
     private EntityStatus status;
 
     private String version;
-    private long lastModified;
+    private Instant lastModified;
     private final EntityReference identity;
     private final EntityDescriptor entityDescriptor;
 
@@ -51,7 +52,7 @@ public final class DefaultEntityState
     private final Map<QualifiedName, List<EntityReference>> manyAssociations;
     private final Map<QualifiedName, Map<String, EntityReference>> namedAssociations;
 
-    public DefaultEntityState( long currentTime,
+    public DefaultEntityState( Instant currentTime,
                                EntityReference identity,
                                EntityDescriptor entityDescriptor
     )
@@ -68,7 +69,7 @@ public final class DefaultEntityState
     }
 
     public DefaultEntityState( String version,
-                               long lastModified,
+                               Instant lastModified,
                                EntityReference identity,
                                EntityStatus status,
                                EntityDescriptor entityDescriptor,
@@ -97,7 +98,7 @@ public final class DefaultEntityState
     }
 
     @Override
-    public long lastModified()
+    public Instant lastModified()
     {
         return lastModified;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
index 5f351d0..2878b76 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONEntityState.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.spi.entitystore.helpers;
 
+import java.time.Instant;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
@@ -59,13 +60,13 @@ public final class JSONEntityState
     private final EntityDescriptor entityDescriptor;
 
     private EntityStatus status;
-    private long lastModified;
+    private Instant lastModified;
     private JSONObject state;
 
     /* package */ JSONEntityState( ModuleDescriptor module,
                                    ValueSerialization valueSerialization,
                                    String version,
-                                   long lastModified,
+                                   Instant lastModified,
                                    EntityReference identity,
                                    EntityStatus status,
                                    EntityDescriptor entityDescriptor,
@@ -90,7 +91,7 @@ public final class JSONEntityState
     }
 
     @Override
-    public long lastModified()
+    public Instant lastModified()
     {
         return lastModified;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java
index 86b5c37..6d3151a 100644
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONKeys.java
@@ -19,6 +19,8 @@
  */
 package org.apache.zest.spi.entitystore.helpers;
 
+import org.apache.zest.api.time.SystemTime;
+
 /**
  * JSON keys for values in the stored data.
  */
@@ -41,7 +43,7 @@ public interface JSONKeys
      */
     String VERSION = "version";
     /**
-     * When entity was last modified according to System.currentTimeMillis().
+     * When entity was last modified according to {@link SystemTime#now()}
      */
     String MODIFIED = "modified";
     /**

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
index 4ba7297..acfbeae 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/JSONMapEntityStoreMixin.java
@@ -25,6 +25,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.Reader;
 import java.io.Writer;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
@@ -138,7 +139,7 @@ public class JSONMapEntityStoreMixin
     // EntityStore
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, Instant currentTime )
     {
         return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
     }
@@ -158,7 +159,7 @@ public class JSONMapEntityStoreMixin
             state.put( JSONKeys.APPLICATION_VERSION, application.version() );
             state.put( JSONKeys.TYPE, entityDescriptor.types().findFirst().get().getName() );
             state.put( JSONKeys.VERSION, unitOfWork.identity() );
-            state.put( JSONKeys.MODIFIED, unitOfWork.currentTime() );
+            state.put( JSONKeys.MODIFIED, unitOfWork.currentTime().toEpochMilli() );
             state.put( JSONKeys.PROPERTIES, new JSONObject() );
             state.put( JSONKeys.ASSOCIATIONS, new JSONObject() );
             state.put( JSONKeys.MANY_ASSOCIATIONS, new JSONObject() );
@@ -406,14 +407,14 @@ public class JSONMapEntityStoreMixin
         return uuid + Integer.toHexString( count++ );
     }
 
-    protected void writeEntityState( JSONEntityState state, Writer writer, String identity, long lastModified )
+    protected void writeEntityState( JSONEntityState state, Writer writer, String identity, Instant lastModified )
         throws EntityStoreException
     {
         try
         {
             JSONObject jsonState = state.state();
             jsonState.put( JSONKeys.VERSION, identity );
-            jsonState.put( JSONKeys.MODIFIED, lastModified );
+            jsonState.put( JSONKeys.MODIFIED, lastModified.toEpochMilli() );
             writer.append( jsonState.toString() );
         }
         catch( JSONException | IOException e )
@@ -431,7 +432,7 @@ public class JSONMapEntityStoreMixin
             EntityStatus status = EntityStatus.LOADED;
 
             String version = jsonObject.getString( JSONKeys.VERSION );
-            long modified = jsonObject.getLong( JSONKeys.MODIFIED );
+            Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
             String identity = jsonObject.getString( JSONKeys.IDENTITY );
 
             // Check if NamedAssociation is supported
@@ -495,7 +496,7 @@ public class JSONMapEntityStoreMixin
         }
     }
 
-    private EntityState fetchCachedState( EntityReference identity, ModuleDescriptor module, long currentTime )
+    private EntityState fetchCachedState( EntityReference identity, ModuleDescriptor module, Instant currentTime )
     {
         CacheState cacheState = cache.get( identity.identity() );
         if( cacheState != null )
@@ -505,7 +506,8 @@ public class JSONMapEntityStoreMixin
             {
                 String type = data.getString( JSONKeys.TYPE );
                 EntityDescriptor entityDescriptor = module.entityDescriptor( type );
-                return new JSONEntityState( module, valueSerialization, data.getString( JSONKeys.VERSION ), data.getLong( JSONKeys.MODIFIED ), identity, EntityStatus.LOADED, entityDescriptor, data );
+                Instant lastModified = Instant.ofEpochMilli(data.getLong(JSONKeys.MODIFIED));
+                return new JSONEntityState( module, valueSerialization, data.getString( JSONKeys.VERSION ), lastModified, identity, EntityStatus.LOADED, entityDescriptor, data );
             }
             catch( JSONException e )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
index adaa340..37b349e 100755
--- a/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
+++ b/core/spi/src/main/java/org/apache/zest/spi/entitystore/helpers/MapEntityStoreMixin.java
@@ -22,6 +22,7 @@ package org.apache.zest.spi.entitystore.helpers;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -108,7 +109,7 @@ public class MapEntityStoreMixin
 
     // EntityStore
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecaseMetaInfo, Instant currentTime )
     {
         return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecaseMetaInfo, currentTime );
     }
@@ -292,7 +293,7 @@ public class MapEntityStoreMixin
         return uuid + Integer.toHexString( count++ );
     }
 
-    protected void writeEntityState( DefaultEntityState state, Writer writer, String version, long lastModified )
+    protected void writeEntityState( DefaultEntityState state, Writer writer, String version, Instant lastModified )
         throws EntityStoreException
     {
         try
@@ -303,7 +304,7 @@ public class MapEntityStoreMixin
                 key( JSONKeys.APPLICATION_VERSION ).value( application.version() ).
                 key( JSONKeys.TYPE ).value( state.entityDescriptor().types().findFirst().get().getName() ).
                 key( JSONKeys.VERSION ).value( version ).
-                key( JSONKeys.MODIFIED ).value( lastModified ).
+                key( JSONKeys.MODIFIED ).value( lastModified.toEpochMilli() ).
                 key( JSONKeys.PROPERTIES ).object();
             EntityDescriptor entityType = state.entityDescriptor();
             entityType.state().properties().forEach( persistentProperty -> {
@@ -387,7 +388,7 @@ public class MapEntityStoreMixin
             final EntityStatus[] status = { EntityStatus.LOADED };
 
             String version = jsonObject.getString( JSONKeys.VERSION );
-            long modified = jsonObject.getLong( JSONKeys.MODIFIED );
+            Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
             String identity = jsonObject.getString( JSONKeys.IDENTITY );
 
             // Check if version is correct

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
index a0c2dd3..3699cf6 100644
--- a/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
+++ b/core/spi/src/test/java/org/apache/zest/spi/entitystore/helpers/JSONManyAssociationStateTest.java
@@ -21,6 +21,7 @@ package org.apache.zest.spi.entitystore.helpers;
 
 import java.util.List;
 import java.util.function.Function;
+import org.apache.zest.api.time.SystemTime;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -51,7 +52,7 @@ public class JSONManyAssociationStateTest
         JSONEntityState entityState = new JSONEntityState( null,
                                                            null,
                                                            "0",
-                                                           System.currentTimeMillis(),
+                                                           SystemTime.now(),
                                                            EntityReference.parseEntityReference( "123" ),
                                                            EntityStatus.NEW,
                                                            null,
@@ -77,7 +78,7 @@ public class JSONManyAssociationStateTest
         JSONEntityState entityState = new JSONEntityState( null,
                                                            null,
                                                            "0",
-                                                           System.currentTimeMillis(),
+                                                           SystemTime.now(),
                                                            EntityReference.parseEntityReference( "123" ),
                                                            EntityStatus.NEW,
                                                            null,

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/core/spi/src/test/java/org/apache/zest/spi/metrics/DefaultMetricsTest.java
----------------------------------------------------------------------
diff --git a/core/spi/src/test/java/org/apache/zest/spi/metrics/DefaultMetricsTest.java b/core/spi/src/test/java/org/apache/zest/spi/metrics/DefaultMetricsTest.java
index e22f76a..a92d526 100644
--- a/core/spi/src/test/java/org/apache/zest/spi/metrics/DefaultMetricsTest.java
+++ b/core/spi/src/test/java/org/apache/zest/spi/metrics/DefaultMetricsTest.java
@@ -20,7 +20,9 @@
 
 package org.apache.zest.spi.metrics;
 
+import java.time.Instant;
 import java.util.concurrent.TimeUnit;
+import org.apache.zest.api.time.SystemTime;
 import org.junit.Test;
 import org.apache.zest.api.metrics.MetricsCounter;
 import org.apache.zest.api.metrics.MetricsCounterFactory;
@@ -55,12 +57,12 @@ public class DefaultMetricsTest
     {
         MetricsProvider underTest = new MetricsProviderAdapter();
         MetricsGaugeFactory factory = underTest.createFactory( MetricsGaugeFactory.class );
-        MetricsGauge<Long> test = factory.registerGauge( getClass(), "test", new MetricsGauge<Long>()
+        MetricsGauge<Instant> test = factory.registerGauge( getClass(), "test", new MetricsGauge<Instant>()
         {
             @Override
-            public Long value()
+            public Instant value()
             {
-                return System.currentTimeMillis();
+                return SystemTime.now();
             }
         } );
         assertNull( test.value() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-jclouds/src/test/java/org/apache/zest/entitystore/jclouds/JCloudsFilesystemTest.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/zest/entitystore/jclouds/JCloudsFilesystemTest.java b/extensions/entitystore-jclouds/src/test/java/org/apache/zest/entitystore/jclouds/JCloudsFilesystemTest.java
index 08a1499..584cb4a 100644
--- a/extensions/entitystore-jclouds/src/test/java/org/apache/zest/entitystore/jclouds/JCloudsFilesystemTest.java
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/zest/entitystore/jclouds/JCloudsFilesystemTest.java
@@ -22,6 +22,7 @@ package org.apache.zest.entitystore.jclouds;
 
 import java.util.HashMap;
 import java.util.Map;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
 import org.jclouds.filesystem.reference.FilesystemConstants;
 import org.junit.AfterClass;
@@ -48,7 +49,7 @@ public class JCloudsFilesystemTest
         JCloudsMapEntityStoreConfiguration defaults = config.forMixin( JCloudsMapEntityStoreConfiguration.class ).declareDefaults();
         defaults.provider().set( "filesystem" );
         Map<String, String> props = new HashMap<String, String>();
-        props.put( FilesystemConstants.PROPERTY_BASEDIR, "build/tmp/" + getClass().getPackage().getName() + "/es-jclouds-" + System.currentTimeMillis() );
+        props.put( FilesystemConstants.PROPERTY_BASEDIR, "build/tmp/" + getClass().getPackage().getName() + "/es-jclouds-" + SystemTime.now().toEpochMilli() );
         defaults.properties().set( props );
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
index 75ae80d..a540c1e 100755
--- a/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
+++ b/extensions/entitystore-preferences/src/main/java/org/apache/zest/entitystore/prefs/PreferencesEntityStoreMixin.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.entitystore.prefs;
 
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -43,13 +44,14 @@ import org.apache.zest.api.service.ServiceDescriptor;
 import org.apache.zest.api.service.qualifier.Tagged;
 import org.apache.zest.api.structure.Application;
 import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.type.CollectionType;
 import org.apache.zest.api.type.EnumType;
 import org.apache.zest.api.type.MapType;
 import org.apache.zest.api.type.ValueCompositeType;
 import org.apache.zest.api.type.ValueType;
-import org.apache.zest.api.unitofwork.NoSuchEntityTypeException;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
+import org.apache.zest.api.unitofwork.NoSuchEntityTypeException;
 import org.apache.zest.api.usecase.Usecase;
 import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.api.value.ValueSerialization;
@@ -168,7 +170,7 @@ public class PreferencesEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime )
     {
         return new DefaultEntityStoreUnitOfWork( module, entityStoreSpi, newUnitOfWorkId(), usecase, currentTime );
     }
@@ -191,7 +193,7 @@ public class PreferencesEntityStoreMixin
                         UsecaseBuilder builder = UsecaseBuilder.buildUsecase( "zest.entitystore.preferences.visit" );
                         Usecase visitUsecase = builder.withMetaInfo( CacheOptions.NEVER ).newUsecase();
                         final EntityStoreUnitOfWork uow =
-                            newUnitOfWork( module, visitUsecase, System.currentTimeMillis() );
+                            newUnitOfWork( module, visitUsecase, SystemTime.now() );
 
                         try
                         {
@@ -414,7 +416,7 @@ public class PreferencesEntityStoreMixin
             } );
 
             return new DefaultEntityState( entityPrefs.get( "version", "" ),
-                                           entityPrefs.getLong( "modified", unitOfWork.currentTime() ),
+                                           Instant.ofEpochMilli(entityPrefs.getLong( "modified", unitOfWork.currentTime().toEpochMilli() )),
                                            identity,
                                            status,
                                            entityDescriptor,
@@ -499,7 +501,7 @@ public class PreferencesEntityStoreMixin
     protected void writeEntityState( DefaultEntityState state,
                                      Preferences entityPrefs,
                                      String identity,
-                                     long lastModified
+                                     Instant lastModified
     )
         throws EntityStoreException
     {
@@ -508,7 +510,7 @@ public class PreferencesEntityStoreMixin
             // Store into Preferences API
             entityPrefs.put( "type", state.entityDescriptor().types().findFirst().get().getName() );
             entityPrefs.put( "version", identity );
-            entityPrefs.putLong( "modified", lastModified );
+            entityPrefs.putLong( "modified", lastModified.toEpochMilli() );
 
             // Properties
             Preferences propsPrefs = entityPrefs.node( "properties" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
index a39a4a8..c541621 100755
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/SQLEntityStoreMixin.java
@@ -28,6 +28,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.time.Instant;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -270,7 +271,7 @@ public class SQLEntityStoreMixin
     }
 
     @Override
-    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, long currentTime )
+    public EntityStoreUnitOfWork newUnitOfWork( ModuleDescriptor module, Usecase usecase, Instant currentTime )
     {
         return new DefaultEntityStoreUnitOfWork( module, entityStoreSPI, newUnitOfWorkId(), usecase, currentTime );
     }
@@ -358,7 +359,7 @@ public class SQLEntityStoreMixin
             final EntityStatus[] status = { EntityStatus.LOADED };
 
             String version = jsonObject.getString( JSONKeys.VERSION );
-            long modified = jsonObject.getLong( JSONKeys.MODIFIED );
+            Instant modified = Instant.ofEpochMilli(jsonObject.getLong( JSONKeys.MODIFIED ));
             String identity = jsonObject.getString( JSONKeys.IDENTITY );
 
             // Check if version is correct
@@ -552,7 +553,7 @@ public class SQLEntityStoreMixin
                 key( JSONKeys.APPLICATION_VERSION ).value( application.version() ).
                 key( JSONKeys.TYPE ).value( state.entityDescriptor().types().findFirst().get().getName() ).
                 key( JSONKeys.VERSION ).value( version ).
-                key( JSONKeys.MODIFIED ).value( state.lastModified() ).
+                key( JSONKeys.MODIFIED ).value( state.lastModified().toEpochMilli() ).
                 key( JSONKeys.PROPERTIES ).object();
 
             state.entityDescriptor().state().properties().forEach( persistentProperty -> {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLService.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLService.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLService.java
index 82bed93..1723e33 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLService.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLService.java
@@ -24,6 +24,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.service.ServiceComposite;
 
@@ -108,10 +109,10 @@ public interface DatabaseSQLService
     void populateGetAllEntitiesStatement( PreparedStatement ps )
         throws SQLException;
 
-    void populateInsertEntityStatement( PreparedStatement ps, EntityReference ref, String entity, Long lastModified )
+    void populateInsertEntityStatement( PreparedStatement ps, EntityReference ref, String entity, Instant lastModified )
         throws SQLException;
 
-    void populateUpdateEntityStatement( PreparedStatement ps, Long entityPK, Long entityOptimisticLock, EntityReference ref, String entity, Long lastModified )
+    void populateUpdateEntityStatement( PreparedStatement ps, Long entityPK, Long entityOptimisticLock, EntityReference ref, String entity, Instant lastModified )
         throws SQLException;
 
     void populateRemoveEntityStatement( PreparedStatement ps, Long entityPK, EntityReference ref )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
index 5765196..a755c19 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/DatabaseSQLServiceStatementsMixin.java
@@ -22,6 +22,7 @@ package org.apache.zest.entitystore.sql.internal;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityReference;
 import org.apache.zest.api.injection.scope.This;
 
@@ -88,12 +89,12 @@ public abstract class DatabaseSQLServiceStatementsMixin
     }
 
     @Override
-    public void populateInsertEntityStatement( PreparedStatement ps, EntityReference ref, String entity, Long lastModified )
+    public void populateInsertEntityStatement( PreparedStatement ps, EntityReference ref, String entity, Instant lastModified )
             throws SQLException
     {
         ps.setString( 1, ref.identity() );
         ps.setString( 2, entity );
-        ps.setLong( 3, lastModified );
+        ps.setLong( 3, lastModified.toEpochMilli() );
     }
 
     @Override
@@ -104,12 +105,12 @@ public abstract class DatabaseSQLServiceStatementsMixin
     }
 
     @Override
-    public void populateUpdateEntityStatement( PreparedStatement ps, Long entityPK, Long entityOptimisticLock, EntityReference ref, String entity, Long lastModified )
+    public void populateUpdateEntityStatement( PreparedStatement ps, Long entityPK, Long entityOptimisticLock, EntityReference ref, String entity, Instant lastModified )
             throws SQLException
     {
         ps.setLong( 1, entityOptimisticLock + 1 );
         ps.setString( 2, entity );
-        ps.setLong( 3, lastModified );
+        ps.setLong( 3, lastModified.toEpochMilli() );
         ps.setLong( 4, entityPK );
         ps.setLong( 5, entityOptimisticLock );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
index 4634b43..3466cbc 100644
--- a/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
+++ b/extensions/entitystore-sql/src/main/java/org/apache/zest/entitystore/sql/internal/SQLEntityState.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.entitystore.sql.internal;
 
+import java.time.Instant;
 import org.apache.zest.api.common.QualifiedName;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.entity.EntityReference;
@@ -33,11 +34,11 @@ public interface SQLEntityState
         extends EntityState
 {
 
-    public Long getEntityPK();
+    Long getEntityPK();
 
-    public Long getEntityOptimisticLock();
+    Long getEntityOptimisticLock();
 
-    public DefaultEntityState getDefaultEntityState();
+    DefaultEntityState getDefaultEntityState();
 
     @SuppressWarnings( "PublicInnerClass" )
     public final class DefaultSQLEntityState
@@ -129,7 +130,7 @@ public interface SQLEntityState
         }
 
         @Override
-        public long lastModified()
+        public Instant lastModified()
         {
             return state.lastModified();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
index f51d512..e05081b 100755
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchIndexer.java
@@ -31,6 +31,7 @@ import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.mixin.Mixins;
 import org.apache.zest.api.service.qualifier.Tagged;
 import org.apache.zest.api.structure.ModuleDescriptor;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.type.ValueType;
 import org.apache.zest.api.usecase.UsecaseBuilder;
 import org.apache.zest.api.util.Classes;
@@ -100,8 +101,9 @@ public interface ElasticSearchIndexer
             }
 
             EntityStoreUnitOfWork uow = entityStore.newUnitOfWork(
-                module, UsecaseBuilder.newUsecase( "Load associations for indexing" ),
-                System.currentTimeMillis()
+                    module,
+                    UsecaseBuilder.newUsecase( "Load associations for indexing" ),
+                    SystemTime.now()
             );
 
             // Bulk index request builder

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
index aef84ee..15a4d7a 100644
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RDFPerformanceTest.java
@@ -25,15 +25,19 @@ package org.apache.zest.index.rdf;
  */
 
 import java.io.File;
-import org.junit.Ignore;
-import org.junit.Test;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.EntityComposite;
-import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
 import org.apache.zest.api.query.QueryExpressions;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
@@ -44,15 +48,13 @@ import org.apache.zest.library.rdf.repository.NativeConfiguration;
 import org.apache.zest.spi.query.IndexExporter;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
+import org.apache.zest.test.util.DelTreeAfter;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.junit.Rule;
-import org.apache.zest.test.util.DelTreeAfter;
-
 public class RDFPerformanceTest extends AbstractZestTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( RDFPerformanceTest.class );
@@ -163,21 +165,21 @@ public class RDFPerformanceTest extends AbstractZestTest
 
     private void performTest( int howMany ) throws Exception
     {
-        long startTest = System.currentTimeMillis();
+        Instant startTest = SystemTime.now();
 
         UnitOfWork creatingUOW = this.unitOfWorkFactory.newUnitOfWork();
-        Long startingTime = System.currentTimeMillis();
+        Instant startingTime = SystemTime.now();
         List<ExampleEntity> entities = this.doCreate( howMany );
-        LOG.info( "Time to create " + howMany + " entities (ms): " + (System.currentTimeMillis() - startingTime) );
+        LOG.info( "Time to create " + howMany + " entities: " + Duration.between(startingTime, SystemTime.now() ) );
 
-        startingTime = System.currentTimeMillis();
+        startingTime = SystemTime.now();
         creatingUOW.complete();
-        LOG.info( "Time to complete creation uow (ms): " + (System.currentTimeMillis() - startingTime) );
+        LOG.info( "Time to complete creation uow: " + Duration.between(startingTime, SystemTime.now() ) );
 
 
         List<ExampleEntity> entityList = this.doList( howMany );
 
-        startingTime = System.currentTimeMillis();
+        startingTime = SystemTime.now();
         UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
         for (int i = 0; i < 1000; i++)
         {
@@ -186,23 +188,21 @@ public class RDFPerformanceTest extends AbstractZestTest
             System.out.println(query.count());
         }
 
-        long endTest = System.currentTimeMillis();
-        LOG.info( "Time to query " + howMany + " entities (ms): " + (endTest - startingTime) );
+        Instant endTest = SystemTime.now();
+        LOG.info( "Time to query " + howMany + " entities: " + Duration.between(startTest, endTest) );
 
         UnitOfWork deletingUOW = this.unitOfWorkFactory.newUnitOfWork();
-        startingTime = System.currentTimeMillis();
+        startingTime = SystemTime.now();
         this.doRemoveAll( entityList );
 //      this.doRemove(200);
-        LOG.info( "Time to delete " + howMany + " entities (ms): " + (System.currentTimeMillis() - startingTime) );
+        LOG.info( "Time to delete " + howMany + " entities: " + Duration.between(startingTime, SystemTime.now() ) );
 
-        startingTime = System.currentTimeMillis();
+        startingTime = SystemTime.now();
         deletingUOW.complete();
 
-        endTest = System.currentTimeMillis();
-
-        LOG.info( "time to complete deletion uow (ms): " + (endTest - startingTime) );
-
-        LOG.info( "time to complete test (ms): " + (endTest - startTest) );
+        endTest = SystemTime.now();
+        LOG.info( "time to complete deletion uow: " + Duration.between(startingTime, endTest ) );
+        LOG.info( "time to complete test: " + Duration.between(startingTime, endTest ) );
 
     }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/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 6f9d6f9..5eabfbc 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
@@ -159,7 +159,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 java.util.Date( entityState.lastModified() ) );
+        input.addField( "lastModified", java.util.Date.from( entityState.lastModified() ) );
 
         for( Statement statement : graph )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java
index faa9aad..d8b7253 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/AbstractSQLIndexing.java
@@ -331,7 +331,7 @@ public abstract class AbstractSQLIndexing
         throws SQLException
     {
         ps.setString( startingIndex, state.identity().identity() );
-        ps.setTimestamp( startingIndex + 1, new Timestamp( state.lastModified() ) );
+        ps.setTimestamp( startingIndex + 1, Timestamp.from( state.lastModified() ) );
         ps.setString( startingIndex + 2, state.version() );
         ps.setString( startingIndex + 3, this._app.version() );
     }
@@ -1006,7 +1006,7 @@ public abstract class AbstractSQLIndexing
 
         // Update state
         ps.setString( 1, state.identity().identity() );
-        ps.setTimestamp( 2, new Timestamp( state.lastModified() ) );
+        ps.setTimestamp( 2, Timestamp.from( state.lastModified() ) );
         ps.setString( 3, state.version() );
         ps.setString( 4, this._app.version() );
         ps.setLong( 5, entityPK );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
index d35716c..3a42b55 100644
--- a/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
+++ b/extensions/indexing-sql/src/main/java/org/apache/zest/index/sql/support/skeletons/SQLCompatEntityStateWrapper.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.index.sql.support.skeletons;
 
+import java.time.Instant;
 import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
@@ -46,7 +47,7 @@ import org.slf4j.LoggerFactory;
  * <p>This allows to disable unsupported properties indexing to prevent failures in the SQL Index/Query engine.</p>
  * <p>When an unsupported Property is found it is logged at WARN level.</p>
  */
-/* package */ class SQLCompatEntityStateWrapper
+class SQLCompatEntityStateWrapper
     implements EntityState
 {
     private static final Logger LOGGER = LoggerFactory.getLogger( SQLCompatEntityStateWrapper.class.getName() );
@@ -108,7 +109,7 @@ import org.slf4j.LoggerFactory;
     }
 
     @Override
-    public long lastModified()
+    public Instant lastModified()
     {
         return wrappedEntityState.lastModified();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/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 32d7473..084dfb7 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
@@ -28,6 +28,7 @@ import javax.management.MBeanNotificationInfo;
 import javax.management.Notification;
 import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.library.circuitbreaker.CircuitBreaker;
 
 /**
@@ -46,12 +47,13 @@ public class CircuitBreakerJMX
       this.circuitBreaker = circuitBreaker;
       circuitBreaker.addPropertyChangeListener(new PropertyChangeListener()
       {
-         long sequenceNr = System.currentTimeMillis();
+         long sequenceNr = SystemTime.now().toEpochMilli();
 
          @Override
          public void propertyChange(PropertyChangeEvent evt)
          {
-            Notification notification = new Notification(evt.getPropertyName(), mbeanObjectName, sequenceNr++, System.currentTimeMillis(), evt.getNewValue().toString());
+            long now = SystemTime.now().toEpochMilli();
+            Notification notification = new Notification(evt.getPropertyName(), mbeanObjectName, sequenceNr++, now, evt.getNewValue().toString());
             sendNotification(notification);
          }
       });

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/fileconfig/src/test/java/org/apache/zest/library/fileconfig/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/libraries/fileconfig/src/test/java/org/apache/zest/library/fileconfig/FileConfigurationTest.java b/libraries/fileconfig/src/test/java/org/apache/zest/library/fileconfig/FileConfigurationTest.java
index 70baf31..850bd83 100644
--- a/libraries/fileconfig/src/test/java/org/apache/zest/library/fileconfig/FileConfigurationTest.java
+++ b/libraries/fileconfig/src/test/java/org/apache/zest/library/fileconfig/FileConfigurationTest.java
@@ -57,7 +57,7 @@ public class FileConfigurationTest
     public void testFileConfigurationOverride()
         throws IOException, ActivationException, AssemblyException
     {
-        File testFile = File.createTempFile( FileConfigurationTest.class.getName(), "" + System.currentTimeMillis() );
+        File testFile = File.createTempFile( FileConfigurationTest.class.getName(), "tmp" );
         final File confDir = testFile;
         final File dataDir = testFile;
         final File tempDir = testFile;

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/records/DebugRecord.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/records/DebugRecord.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/records/DebugRecord.java
index f47c9a0..c412bc8 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/records/DebugRecord.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/records/DebugRecord.java
@@ -21,6 +21,7 @@
 package org.apache.zest.library.logging.debug.records;
 
 import java.io.Serializable;
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.property.Property;
 
@@ -32,7 +33,7 @@ public interface DebugRecord
 
     Property<String> threadName();
 
-    Property<Long> time();
+    Property<Instant> time();
 
     Property<List<Serializable>> parameters();
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/service/DebuggingServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/service/DebuggingServiceMixin.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/service/DebuggingServiceMixin.java
index cfc9395..5d8fd9c 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/service/DebuggingServiceMixin.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/debug/service/DebuggingServiceMixin.java
@@ -32,6 +32,7 @@ import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.api.service.ServiceComposite;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -166,7 +167,7 @@ public class DebuggingServiceMixin
 
     private void setStandardStuff( Composite composite, String message, DebugRecord state, List<Serializable> params )
     {
-        state.time().set( System.currentTimeMillis() );
+        state.time().set( SystemTime.now() );
         state.message().set( message );
         state.compositeTypeName().set( getCompositeName( composite ) );
         state.threadName().set( Thread.currentThread().getName() );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/records/LogRecord.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/records/LogRecord.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/log/records/LogRecord.java
index 03706b6..3de0dde 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/records/LogRecord.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/log/records/LogRecord.java
@@ -20,6 +20,7 @@
 package org.apache.zest.library.logging.log.records;
 
 import java.io.Serializable;
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.library.logging.log.LogType;
@@ -36,7 +37,7 @@ public interface LogRecord
 
     Property<LogType> logtype();
 
-    Property<Long> time();
+    Property<Instant> time();
 
     Property<List<Serializable>> parameters();
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/service/LoggingServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/service/LoggingServiceMixin.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/log/service/LoggingServiceMixin.java
index df59579..4431865 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/log/service/LoggingServiceMixin.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/log/service/LoggingServiceMixin.java
@@ -30,6 +30,7 @@ import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.service.ServiceComposite;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.api.unitofwork.ConcurrentEntityModificationException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
@@ -158,7 +159,7 @@ public abstract class LoggingServiceMixin
                                    LogRecord state, List<Serializable> params )
     {
         state.logtype().set( type );
-        state.time().set( System.currentTimeMillis() );
+        state.time().set( SystemTime.now() );
         state.category().set( category );
         state.message().set( message );
         state.compositeTypeName().set( getCompositeName( composite ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/AbstractTraceConcern.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/AbstractTraceConcern.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/AbstractTraceConcern.java
index 1575ac8..c3860bf 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/AbstractTraceConcern.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/AbstractTraceConcern.java
@@ -22,12 +22,15 @@ package org.apache.zest.library.logging.trace;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
 import org.apache.zest.api.ZestAPI;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.concern.ConcernOf;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
+import org.apache.zest.api.time.SystemTime;
 import org.apache.zest.library.logging.trace.service.TraceService;
 
 
@@ -51,19 +54,13 @@ public abstract class AbstractTraceConcern extends ConcernOf<InvocationHandler>
     {
         boolean doTrace = traceService != null && doTrace();
         Object result;
-        long entryTime = 0;
-        long timeStamp = 0;
+        Instant entryTime = SystemTime.now();;
         try
         {
-            if( doTrace )
-            {
-                entryTime = System.currentTimeMillis();
-                timeStamp = System.nanoTime();
-            }
             result = next.invoke( proxy, method, args );
             if( doTrace )
             {
-                long duration = System.nanoTime() - timeStamp;
+                Duration duration = Duration.between(entryTime, SystemTime.now() );
                 traceService.traceSuccess( compositeType, api.dereference( thisComposite ), method, args, result, entryTime, duration );
             }
         }
@@ -71,7 +68,7 @@ public abstract class AbstractTraceConcern extends ConcernOf<InvocationHandler>
         {
             if( doTrace )
             {
-                long duration = System.nanoTime() - timeStamp;
+                Duration duration = Duration.between(entryTime, SystemTime.now() );
                 Composite object = api.dereference( thisComposite );
                 traceService.traceException( compositeType, object, method, args, t, entryTime, duration );
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/TraceOnConsoleSideEffect.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/TraceOnConsoleSideEffect.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/TraceOnConsoleSideEffect.java
index 0ed54e1..6497810 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/TraceOnConsoleSideEffect.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/TraceOnConsoleSideEffect.java
@@ -22,6 +22,8 @@ package org.apache.zest.library.logging.trace;
 
 import java.io.PrintStream;
 import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.sideeffect.SideEffectOf;
 import org.apache.zest.library.logging.trace.service.TraceService;
@@ -36,23 +38,23 @@ public abstract class TraceOnConsoleSideEffect extends SideEffectOf<TraceService
     private static PrintStream OUT = System.err;
 
     @Override
-    public void traceSuccess( Class compositeType, Composite object, Method method, Object[] args, Object result, long entryTime, long durationNano )
+    public void traceSuccess(Class compositeType, Composite object, Method method, Object[] args, Object result, Instant entryTime, Duration duration )
     {
         StringBuffer buf = new StringBuffer();
-        buf.append( durationNano / 1000000 );
-        buf.append( " ms: " );
+        buf.append( duration );
+        buf.append( " : " );
         formatMethod( buf, object, compositeType, method, args );
         OUT.println( buf.toString() );
         OUT.println( result );
     }
 
     @Override
-    public void traceException( Class compositeType, Composite object, Method method, Object[] args, Throwable t, long entryTime, long durationNano )
+    public void traceException( Class compositeType, Composite object, Method method, Object[] args, Throwable t, Instant entryTime, Duration duration )
     {
         StringBuffer buf = new StringBuffer();
         buf.append( "Exception: " );
-        buf.append( durationNano / 1000000 );
-        buf.append( " ms: " );
+        buf.append( duration );
+        buf.append( " : " );
         OUT.println( buf.toString() );
         t.printStackTrace( OUT );
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/records/TraceRecord.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/records/TraceRecord.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/records/TraceRecord.java
index f60f51f..bbf6f7d 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/records/TraceRecord.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/records/TraceRecord.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.library.logging.trace.records;
 
+import java.time.Duration;
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.entity.Queryable;
@@ -33,9 +35,9 @@ public interface TraceRecord
 
     Property<String> threadName();
 
-    Property<Long> entryTime();
+    Property<Instant> entryTime();
 
-    Property<Long> duration();
+    Property<Duration> duration();
 
     @Optional Property<Throwable> exception();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/e030bd8a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/service/TraceService.java
----------------------------------------------------------------------
diff --git a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/service/TraceService.java b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/service/TraceService.java
index 4f222c9..03184d8 100644
--- a/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/service/TraceService.java
+++ b/libraries/logging/src/main/java/org/apache/zest/library/logging/trace/service/TraceService.java
@@ -21,6 +21,8 @@
 package org.apache.zest.library.logging.trace.service;
 
 import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
 import org.apache.zest.api.common.Optional;
 import org.apache.zest.api.composite.Composite;
 
@@ -28,8 +30,8 @@ public interface TraceService
 {
     int traceLevel();
 
-    void traceSuccess( Class compositeType, Composite object, Method method, @Optional Object[] args, Object result, long entryTime, long durationNano );
+    void traceSuccess(Class compositeType, Composite object, Method method, @Optional Object[] args, Object result, Instant entryTime, Duration duration );
 
-    void traceException( Class compositeType, Composite object, Method method, @Optional Object[] args, Throwable t, long entryTime, long durationNano );
+    void traceException( Class compositeType, Composite object, Method method, @Optional Object[] args, Throwable t, Instant entryTime, Duration duration );
 
 }


Mime
View raw message