polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [5/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:06 GMT
http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
----------------------------------------------------------------------
diff --git a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
index 4c3078d..81268ef 100644
--- a/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
+++ b/libraries/rdf/src/main/java/org/apache/zest/library/rdf/entity/EntityTypeSerializer.java
@@ -21,16 +21,20 @@
 package org.apache.zest.library.rdf.entity;
 
 import java.math.BigDecimal;
-import java.util.Date;
+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.HashMap;
 import java.util.Map;
 import org.apache.zest.api.entity.EntityDescriptor;
 import org.apache.zest.api.util.Classes;
 import org.apache.zest.library.rdf.Rdfs;
 import org.apache.zest.library.rdf.ZestEntityType;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalDateTime;
 import org.openrdf.model.Graph;
 import org.openrdf.model.Statement;
 import org.openrdf.model.URI;
@@ -58,10 +62,14 @@ public class EntityTypeSerializer
         dataTypes.put( Double.class.getName(), XMLSchema.DOUBLE );
         dataTypes.put( Long.class.getName(), XMLSchema.LONG );
         dataTypes.put( Short.class.getName(), XMLSchema.SHORT );
-        dataTypes.put( Date.class.getName(), XMLSchema.DATETIME );
-        dataTypes.put( DateTime.class.getName(), XMLSchema.DATETIME );
+        dataTypes.put( Instant.class.getName(), XMLSchema.LONG );
+        dataTypes.put( OffsetDateTime.class.getName(), XMLSchema.DATETIME );
+        dataTypes.put( ZonedDateTime.class.getName(), XMLSchema.DATETIME );
         dataTypes.put( LocalDateTime.class.getName(), XMLSchema.DATETIME );
         dataTypes.put( LocalDate.class.getName(), XMLSchema.DATE );
+        dataTypes.put( LocalTime.class.getName(), XMLSchema.TIME );
+        dataTypes.put( Duration.class.getName(), XMLSchema.DURATION );
+        dataTypes.put( Period.class.getName(), XMLSchema.DURATION );
     }
 
     public Iterable<Statement> serialize( final EntityDescriptor entityDescriptor )
@@ -73,10 +81,10 @@ public class EntityTypeSerializer
         graph.add( entityTypeUri, Rdfs.TYPE, Rdfs.CLASS );
         graph.add( entityTypeUri, Rdfs.TYPE, OWL.CLASS );
 
-        graph.add( entityTypeUri, ZestEntityType.TYPE, values.createLiteral( entityDescriptor.types()
-                                                                                 .findFirst()
-                                                                                 .get()
-                                                                                 .toString() ) );
+        graph.add( entityTypeUri,
+                   ZestEntityType.TYPE,
+                   values.createLiteral( entityDescriptor.types().findFirst().get().toString() )
+        );
         graph.add( entityTypeUri, ZestEntityType.QUERYABLE, values.createLiteral( entityDescriptor.queryable() ) );
 
         serializeMixinTypes( entityDescriptor, graph, entityTypeUri );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
index 6b3a21e..300ca20 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/ClientCache.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.rest.client;
 
-import java.util.Date;
+import java.time.Instant;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -30,123 +30,120 @@ import org.restlet.data.Method;
 import org.restlet.data.Reference;
 import org.restlet.data.Tag;
 
+import static java.util.Date.from;
+
 /**
  * Cache for the ContextResourceClient. This is primarily used to keep track of ETags and lastmodified timestamps for now.
  */
 public class ClientCache
 {
-   Map<String, CacheInfo> identityToTimestamp = new HashMap<String, CacheInfo>( );
-   Map<String, String> pathToIdentity = new HashMap<String, String>( );
-
-   public void updateCache( Response response)
-   {
-      if (response.getRequest().getMethod().equals( Method.DELETE ))
-      {
-         String path = getIdentityPath( response.getRequest().getResourceRef() );
-         String id = pathToIdentity.get( path );
-         if (id != null)
-         {
-            // Clear anything related to this id from cache
-            identityToTimestamp.remove( id );
-            Iterator<Map.Entry<String, String>> paths = pathToIdentity.entrySet().iterator();
-            while (paths.hasNext())
+    private Map<String, CacheInfo> identityToTimestamp = new HashMap<>();
+    private Map<String, String> pathToIdentity = new HashMap<>();
+
+    public void updateCache( Response response )
+    {
+        if( response.getRequest().getMethod().equals( Method.DELETE ) )
+        {
+            String path = getIdentityPath( response.getRequest().getResourceRef() );
+            String id = pathToIdentity.get( path );
+            if( id != null )
             {
-               Map.Entry<String, String> entry = paths.next();
-               if (entry.getValue().equals( id ))
-                  paths.remove();
+                // Clear anything related to this id from cache
+                identityToTimestamp.remove( id );
+                Iterator<Map.Entry<String, String>> paths = pathToIdentity.entrySet().iterator();
+                while( paths.hasNext() )
+                {
+                    Map.Entry<String, String> entry = paths.next();
+                    if( entry.getValue().equals( id ) )
+                    {
+                        paths.remove();
+                    }
+                }
             }
-         }
-      } else if (response.getRequest().getMethod().equals( Method.PUT ) || response.getRequest().getMethod().equals( Method.POST ))
-      {
-         Tag tag = response.getEntity().getTag();
-         if (tag != null)
-         {
-            Reference ref = response.getRequest().getResourceRef().clone();
+        }
+        else if( response.getRequest().getMethod().equals( Method.PUT ) || response.getRequest()
+            .getMethod()
+            .equals( Method.POST ) )
+        {
+            Tag tag = response.getEntity().getTag();
+            if( tag != null )
+            {
+                Reference ref = response.getRequest().getResourceRef().clone();
 
-            CacheInfo value = new CacheInfo( response.getEntity().getModificationDate(), tag, ref );
-            identityToTimestamp.put( value.getEntity(), value );
+                CacheInfo value = new CacheInfo( response.getEntity().getModificationDate().toInstant(), tag);
+                identityToTimestamp.put( value.getEntity(), value );
 
-            String path = getIdentityPath( ref );
+                String path = getIdentityPath( ref );
 
-            pathToIdentity.put( path, value.getEntity() );
+                pathToIdentity.put( path, value.getEntity() );
 
 //            LoggerFactory.getLogger( ClientCache.class ).info( "Update:"+value.getEntity()+" ("+ref.toString()+") -> "+value.getLastModified() );
-         }
-      } else
-      {
-          // TODO GET caching goes here
-      }
-   }
-
-   public void updateQueryConditions( Request request)
-   {
-      String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ));
-      if (identity != null)
-      {
-         CacheInfo cacheInfo = identityToTimestamp.get( identity );
-         if (cacheInfo != null)
-         {
+            }
+        }
+        else
+        {
+            // TODO GET caching goes here
+            System.out.println("Caching of GET is not implemented...");
+        }
+    }
+
+    public void updateQueryConditions( Request request )
+    {
+        String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
+        if( identity != null )
+        {
+            CacheInfo cacheInfo = identityToTimestamp.get( identity );
+            if( cacheInfo != null )
+            {
 //            LoggerFactory.getLogger( ClientCache.class ).info( "Send:  "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
-            request.getConditions().setModifiedSince( cacheInfo.getLastModified() );
-         }
-      }
-   }
-
-   public void updateCommandConditions( Request request)
-   {
-      String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ));
-      if (identity != null)
-      {
-         CacheInfo cacheInfo = identityToTimestamp.get( identity );
-         if (cacheInfo != null)
-         {
+                request.getConditions().setModifiedSince( from( cacheInfo.getLastModified() ) );
+            }
+        }
+    }
+
+    public void updateCommandConditions( Request request )
+    {
+        String identity = pathToIdentity.get( getIdentityPath( request.getResourceRef() ) );
+        if( identity != null )
+        {
+            CacheInfo cacheInfo = identityToTimestamp.get( identity );
+            if( cacheInfo != null )
+            {
 //            LoggerFactory.getLogger( ClientCache.class ).info( "Send:  "+cacheInfo.getEntity()+" ("+request.getMethod().getName()+":"+request.getResourceRef()+") -> "+cacheInfo.getLastModified() );
-            request.getConditions().setUnmodifiedSince( cacheInfo.getLastModified() );
-         }
-      }
-   }
-
-   private String getIdentityPath( Reference ref )
-   {
-      String path = ref.getPath();
-      if (!path.endsWith( "/" ))
-         path = path.substring( 0, path.lastIndexOf('/' )+1);
-      return path;
-   }
-
-   static class CacheInfo
-   {
-      private Reference ref;
-      private Date lastModified;
-      private Tag tag;
-      private String entity;
-
-      CacheInfo( Date lastModified, Tag tag, Reference ref )
-      {
-         this.lastModified = lastModified;
-         this.tag = tag;
-         this.ref = ref;
-         entity = tag.getName().split( "/" )[0];
-      }
-
-      public Reference getRef()
-      {
-         return ref;
-      }
-
-      public Date getLastModified()
-      {
-         return lastModified;
-      }
-
-      public Tag getTag()
-      {
-         return tag;
-      }
-
-      public String getEntity()
-      {
-         return entity;
-      }
-   }
+                request.getConditions().setUnmodifiedSince( from( cacheInfo.getLastModified() ) );
+            }
+        }
+    }
+
+    private String getIdentityPath( Reference ref )
+    {
+        String path = ref.getPath();
+        if( !path.endsWith( "/" ) )
+        {
+            path = path.substring( 0, path.lastIndexOf( '/' ) + 1 );
+        }
+        return path;
+    }
+
+    private static class CacheInfo
+    {
+        private Instant lastModified;
+        private String entity;
+
+        CacheInfo( Instant lastModified, Tag tag )
+        {
+            this.lastModified = lastModified;
+            entity = tag.getName().split( "/" )[ 0 ];
+        }
+
+        Instant getLastModified()
+        {
+            return lastModified;
+        }
+
+        String getEntity()
+        {
+            return entity;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
index 46d7b79..a34b635 100644
--- a/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
+++ b/libraries/rest-client/src/main/java/org/apache/zest/library/rest/client/responsereader/TableResponseReader.java
@@ -20,17 +20,17 @@
 
 package org.apache.zest.library.rest.client.responsereader;
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
 import org.apache.zest.api.injection.scope.Structure;
 import org.apache.zest.api.structure.Module;
-import org.apache.zest.api.util.Dates;
 import org.apache.zest.library.rest.client.spi.ResponseReader;
 import org.apache.zest.library.rest.common.table.Table;
 import org.apache.zest.library.rest.common.table.TableBuilder;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
 import org.restlet.Response;
 import org.restlet.data.MediaType;
 import org.restlet.data.Status;
@@ -78,20 +78,20 @@ public class TableResponseReader
                   String formatted = cell.optString("f");
 
                   if (cols.getJSONObject( j ).getString( "type" ).equals("datetime") && value != null)
-                     value = Dates.fromString( value.toString() );
+                     value = ZonedDateTime.parse( value.toString() );
                   else if (cols.getJSONObject( j ).getString( "type" ).equals("date") && value != null)
                      try
                      {
-                        value = new SimpleDateFormat( "yyyy-MM-dd").parse( value.toString() );
-                     } catch (ParseException e)
+                        value = DateTimeFormatter.ofPattern( "yyyy-MM-dd").parse( value.toString() );
+                     } catch (DateTimeParseException e)
                      {
                         throw new ResourceException(e);
                      }
                   else if (cols.getJSONObject( j ).getString( "type" ).equals("timeofday") && value != null)
                      try
                      {
-                        value = new SimpleDateFormat( "HH:mm:ss").parse( value.toString() );
-                     } catch (ParseException e)
+                        value = DateTimeFormatter.ofPattern(  "HH:mm:ss").parse( value.toString() );
+                     } catch (DateTimeParseException e)
                      {
                         throw new ResourceException(e);
                      }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
index 885a2c0..2143c6d 100644
--- a/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
+++ b/libraries/rest-common/src/main/java/org/apache/zest/library/rest/common/table/TableBuilder.java
@@ -19,14 +19,11 @@
  */
 package org.apache.zest.library.rest.common.table;
 
-import java.text.SimpleDateFormat;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
-import org.apache.zest.api.util.Dates;
 import org.apache.zest.api.value.ValueBuilder;
 import org.apache.zest.api.value.ValueBuilderFactory;
 
@@ -37,191 +34,215 @@ import static java.util.Collections.reverseOrder;
  */
 public class TableBuilder
 {
-   protected ValueBuilderFactory vbf;
-   private Map<String, TableBuilderFactory.Column> columns;
-   private TableQuery tableQuery;
-
-   protected ValueBuilder<Table> tableBuilder;
-
-   protected ValueBuilder<Row> rowBuilder;
-
-   public TableBuilder(ValueBuilderFactory vbf)
-   {
-      this.vbf = vbf;
-
-      tableBuilder = vbf.newValueBuilder(Table.class);
-   }
-
-   public TableBuilder(ValueBuilderFactory vbf, Map<String, TableBuilderFactory.Column> columns, TableQuery tableQuery)
-   {
-      this.vbf = vbf;
-      this.columns = columns;
-      this.tableQuery = tableQuery;
-
-      tableBuilder = vbf.newValueBuilder(Table.class);
-
-      if (tableQuery.select().equals("*"))
-      {
-         for (TableBuilderFactory.Column column : columns.values())
-         {
-            column(column.getId(), column.getLabel(), column.getType());
-         }
-      } else
-      {
-         for (String columnName : tableQuery.select().split("[, ]"))
-         {
-            TableBuilderFactory.Column column = columns.get(columnName.trim());
-            if (column != null)
-               column(column.getId(), column.getLabel(), column.getType());
-         }
-      }
-   }
-
-   public TableBuilder column(String id, String label, String type)
-   {
-      ValueBuilder<Column> builder = vbf.newValueBuilder(Column.class);
-      builder.prototype().id().set(id);
-
-      if (tableQuery != null && tableQuery.label() != null)
-      {
-         // TODO Fix label selection
-      }
-
-      builder.prototype().label().set(label);
-      builder.prototype().columnType().set(type);
-      tableBuilder.prototype().cols().get().add(builder.newInstance());
-      return this;
-   }
-
-   public TableBuilder rows(Iterable<?> rowObjects)
-   {
-      boolean no_format = false;
-      boolean no_values = false;
-      if (tableQuery != null && tableQuery.options() != null)
-      {
-         if (tableQuery.options().contains("no_format"))
-            no_format = true;
-         if (tableQuery != null && tableQuery.options().contains("no_values"))
-            no_values = true;
-      }
-
-      for (Object rowObject : rowObjects)
-      {
-         row();
-         for (Column column : tableBuilder.prototype().cols().get())
-         {
-            Object v = null;
-            String f = null;
-            Function valueFunction = columns.get( column.id().get()).getValueFunction();
-            if (!no_values && valueFunction != null)
-               v = valueFunction.apply( rowObject );
-            Function formattedFunction = columns.get( column.id().get()).getFormattedFunction();
-            if (!no_format && formattedFunction != null)
-               f = (String) formattedFunction.apply(rowObject);
-            else if (v != null)
+    protected ValueBuilderFactory vbf;
+    private Map<String, TableBuilderFactory.Column> columns;
+    private TableQuery tableQuery;
+
+    protected ValueBuilder<Table> tableBuilder;
+
+    protected ValueBuilder<Row> rowBuilder;
+
+    public TableBuilder( ValueBuilderFactory vbf )
+    {
+        this.vbf = vbf;
+
+        tableBuilder = vbf.newValueBuilder( Table.class );
+    }
+
+    public TableBuilder( ValueBuilderFactory vbf,
+                         Map<String, TableBuilderFactory.Column> columns,
+                         TableQuery tableQuery
+    )
+    {
+        this.vbf = vbf;
+        this.columns = columns;
+        this.tableQuery = tableQuery;
+
+        tableBuilder = vbf.newValueBuilder( Table.class );
+
+        if( tableQuery.select().equals( "*" ) )
+        {
+            for( TableBuilderFactory.Column column : columns.values() )
             {
-               if ( column.columnType().get().equals( Table.DATETIME))
-                  f = Dates.toUtcString( (Date) v );
-               else if ( column.columnType().get().equals( Table.DATE))
-                  f = new SimpleDateFormat( "yyyy-MM-dd").format((Date) v);
-               else if ( column.columnType().get().equals( Table.TIME_OF_DAY))
-                  f = new SimpleDateFormat( "HH:mm:ss").format((Date) v);
-               else
-                  f = v.toString();
+                column( column.getId(), column.getLabel(), column.getType() );
             }
-
-            cell(v, f);
-         }
-         endRow();
-      }
-
-      return this;
-   }
-
-   public TableBuilder row()
-   {
-      if (rowBuilder != null)
-         endRow();
-
-      rowBuilder = vbf.newValueBuilder(Row.class);
-      return this;
-   }
-
-   public TableBuilder endRow()
-   {
-      tableBuilder.prototype().rows().get().add(rowBuilder.newInstance());
-      rowBuilder = null;
-      return this;
-   }
-
-   public TableBuilder cell(Object v, String f)
-   {
-      ValueBuilder<Cell> cellBuilder = vbf.newValueBuilder(Cell.class);
-      cellBuilder.prototype().v().set(v);
-      cellBuilder.prototype().f().set(f);
-      rowBuilder.prototype().c().get().add(cellBuilder.newInstance());
-      return this;
-   }
-
-   public TableBuilder orderBy()
-   {
-      if (tableQuery.orderBy() != null)
-      {
-         // Sort table
-         // Find sort column index
-
-         String[] orderBy = tableQuery.orderBy().split(" ");
-         boolean descending = orderBy.length == 2 && orderBy[1].equals("desc");
-
-         int sortIndex = -1;
-         List<Column> columns = tableBuilder.prototype().cols().get();
-         for (int i = 0; i < columns.size(); i++)
-         {
-            Column column = columns.get(i);
-            if ( column.id().get().equals(orderBy[0]))
+        }
+        else
+        {
+            for( String columnName : tableQuery.select().split( "[, ]" ) )
             {
-               sortIndex = i;
-               break;
+                TableBuilderFactory.Column column = columns.get( columnName.trim() );
+                if( column != null )
+                {
+                    column( column.getId(), column.getLabel(), column.getType() );
+                }
             }
+        }
+    }
+
+    public TableBuilder column( String id, String label, String type )
+    {
+        ValueBuilder<Column> builder = vbf.newValueBuilder( Column.class );
+        builder.prototype().id().set( id );
+
+        if( tableQuery != null && tableQuery.label() != null )
+        {
+            // TODO Fix label selection
+        }
+
+        builder.prototype().label().set( label );
+        builder.prototype().columnType().set( type );
+        tableBuilder.prototype().cols().get().add( builder.newInstance() );
+        return this;
+    }
+
+    public TableBuilder rows( Iterable<?> rowObjects )
+    {
+        boolean no_format = false;
+        boolean no_values = false;
+        if( tableQuery != null && tableQuery.options() != null )
+        {
+            if( tableQuery.options().contains( "no_format" ) )
+            {
+                no_format = true;
+            }
+            if( tableQuery != null && tableQuery.options().contains( "no_values" ) )
+            {
+                no_values = true;
+            }
+        }
 
-         }
-
-         if (sortIndex != -1)
-         {
-            final int idx = sortIndex;
-            Comparator<Row> comparator = new Comparator<Row>()
+        for( Object rowObject : rowObjects )
+        {
+            row();
+            for( Column column : tableBuilder.prototype().cols().get() )
             {
-               @Override
-               public int compare(Row o1, Row o2)
-               {
-                  Object o = o1.c().get().get(idx).v().get();
-
-                  if (o != null && o instanceof Comparable)
-                  {
-                     Comparable c1 = (Comparable) o;
-                     Comparable c2 = (Comparable) o2.c().get().get(idx).v().get();
-                     return c1.compareTo(c2);
-                  } else
-                  {
-                     String f1 = o1.c().get().get(idx).f().get();
-                     String f2 = o2.c().get().get(idx).f().get();
-                     return f1.compareTo(f2);
-                  }
-               }
-            };
-
-            if (descending)
+                Object v = null;
+                String f = null;
+                Function valueFunction = columns.get( column.id().get() ).getValueFunction();
+                if( !no_values && valueFunction != null )
+                {
+                    v = valueFunction.apply( rowObject );
+                }
+                Function formattedFunction = columns.get( column.id().get() ).getFormattedFunction();
+                if( !no_format && formattedFunction != null )
+                {
+                    f = (String) formattedFunction.apply( rowObject );
+                }
+                else if( v != null )
+                {
+                    if( column.columnType().get().equals( Table.DATETIME ) )
+                    {
+                        f = v.toString();
+                    }
+                    else if( column.columnType().get().equals( Table.DATE ) )
+                    {
+                        f = v.toString();
+                    }
+                    else if( column.columnType().get().equals( Table.TIME_OF_DAY ) )
+                    {
+                        f = v.toString();
+                    }
+                    else
+                    {
+                        f = v.toString();
+                    }
+                }
+
+                cell( v, f );
+            }
+            endRow();
+        }
+
+        return this;
+    }
+
+    public TableBuilder row()
+    {
+        if( rowBuilder != null )
+        {
+            endRow();
+        }
+
+        rowBuilder = vbf.newValueBuilder( Row.class );
+        return this;
+    }
+
+    public TableBuilder endRow()
+    {
+        tableBuilder.prototype().rows().get().add( rowBuilder.newInstance() );
+        rowBuilder = null;
+        return this;
+    }
+
+    public TableBuilder cell( Object v, String f )
+    {
+        ValueBuilder<Cell> cellBuilder = vbf.newValueBuilder( Cell.class );
+        cellBuilder.prototype().v().set( v );
+        cellBuilder.prototype().f().set( f );
+        rowBuilder.prototype().c().get().add( cellBuilder.newInstance() );
+        return this;
+    }
+
+    public TableBuilder orderBy()
+    {
+        if( tableQuery.orderBy() != null )
+        {
+            // Sort table
+            // Find sort column index
+
+            String[] orderBy = tableQuery.orderBy().split( " " );
+            boolean descending = orderBy.length == 2 && orderBy[ 1 ].equals( "desc" );
+
+            int sortIndex = -1;
+            List<Column> columns = tableBuilder.prototype().cols().get();
+            for( int i = 0; i < columns.size(); i++ )
             {
-               // Flip it
-               comparator = reverseOrder(comparator);
+                Column column = columns.get( i );
+                if( column.id().get().equals( orderBy[ 0 ] ) )
+                {
+                    sortIndex = i;
+                    break;
+                }
             }
 
-            Collections.sort(tableBuilder.prototype().rows().get(), comparator);
-         }
-      }
+            if( sortIndex != -1 )
+            {
+                final int idx = sortIndex;
+                Comparator<Row> comparator = new Comparator<Row>()
+                {
+                    @Override
+                    public int compare( Row o1, Row o2 )
+                    {
+                        Object o = o1.c().get().get( idx ).v().get();
+
+                        if( o != null && o instanceof Comparable )
+                        {
+                            Comparable c1 = (Comparable) o;
+                            Comparable c2 = (Comparable) o2.c().get().get( idx ).v().get();
+                            return c1.compareTo( c2 );
+                        }
+                        else
+                        {
+                            String f1 = o1.c().get().get( idx ).f().get();
+                            String f2 = o2.c().get().get( idx ).f().get();
+                            return f1.compareTo( f2 );
+                        }
+                    }
+                };
+
+                if( descending )
+                {
+                    // Flip it
+                    comparator = reverseOrder( comparator );
+                }
+
+                Collections.sort( tableBuilder.prototype().rows().get(), comparator );
+            }
+        }
 
-      return this;
-   }
+        return this;
+    }
 
 //   public TableBuilder orderBy()
 //   {
@@ -272,33 +293,40 @@ public class TableBuilder
 //      return this;
 //   }
 
-   public TableBuilder paging()
-   {
-      // Paging
-      int start = 0;
-      int end = tableBuilder.prototype().rows().get().size();
-      if (tableQuery.offset() != null)
-         start = Integer.parseInt(tableQuery.offset());
-      if (tableQuery.limit() != null)
-         end = Math.min(end, start + Integer.parseInt(tableQuery.limit()));
-
-      if (!(start == 0 && end == tableBuilder.prototype().rows().get().size()))
-         tableBuilder.prototype().rows().set(tableBuilder.prototype().rows().get().subList(start, end));
-
-      return this;
-
-   }
-
-   public Table newTable()
-   {
-      if (rowBuilder != null)
-         endRow();
-
-      return tableBuilder.newInstance();
-   }
-
-   public void abortRow()
-   {
-      rowBuilder = null;
-   }
+    public TableBuilder paging()
+    {
+        // Paging
+        int start = 0;
+        int end = tableBuilder.prototype().rows().get().size();
+        if( tableQuery.offset() != null )
+        {
+            start = Integer.parseInt( tableQuery.offset() );
+        }
+        if( tableQuery.limit() != null )
+        {
+            end = Math.min( end, start + Integer.parseInt( tableQuery.limit() ) );
+        }
+
+        if( !( start == 0 && end == tableBuilder.prototype().rows().get().size() ) )
+        {
+            tableBuilder.prototype().rows().set( tableBuilder.prototype().rows().get().subList( start, end ) );
+        }
+
+        return this;
+    }
+
+    public Table newTable()
+    {
+        if( rowBuilder != null )
+        {
+            endRow();
+        }
+
+        return tableBuilder.newInstance();
+    }
+
+    public void abortRow()
+    {
+        rowBuilder = null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
index 5b3ca7e..e92338b 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/api/ResourceValidity.java
@@ -20,7 +20,7 @@
 
 package org.apache.zest.library.rest.server.api;
 
-import java.util.Date;
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.unitofwork.NoSuchEntityException;
 import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -35,20 +35,20 @@ import org.restlet.resource.ResourceException;
 /**
  * JAVADOC
  */
-public class ResourceValidity
+class ResourceValidity
 {
-    EntityComposite entity;
+    private EntityComposite entity;
     private final ZestSPI spi;
     private Request request;
 
-    public ResourceValidity( EntityComposite entity, ZestSPI spi, Request request )
+    ResourceValidity( EntityComposite entity, ZestSPI spi, Request request )
     {
         this.entity = entity;
         this.spi = spi;
         this.request = request;
     }
 
-    public void updateEntity( UnitOfWork current )
+    void updateEntity( UnitOfWork current )
     {
         try
         {
@@ -61,43 +61,45 @@ public class ResourceValidity
         }
     }
 
-    public void updateResponse( Response response )
+    void updateResponse( Response response )
     {
         if( entity != null )
         {
             EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( state.lastModified() );
             Tag tag = new Tag( state.identity().identity() + "/" + state.version() );
-            response.getEntity().setModificationDate( lastModified );
+            response.getEntity().setModificationDate( new java.util.Date( state.lastModified() ) );
             response.getEntity().setTag( tag );
         }
     }
 
-    public void checkRequest()
+    void checkRequest()
         throws ResourceException
     {
         // Check command rules
-        Date modificationDate = request.getConditions().getUnmodifiedSince();
-        if( modificationDate != null )
+        Instant unmodifiedSince = request.getConditions().getUnmodifiedSince().toInstant();
+        EntityState state = spi.entityStateOf( entity );
+        Instant lastModified = cutoffMillis( state.lastModified() );
+        if( unmodifiedSince != null )
         {
-            EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
-            if( lastModified.after( modificationDate ) )
+            if( lastModified.isAfter( unmodifiedSince ) )
             {
                 throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
             }
         }
 
         // Check query rules
-        modificationDate = request.getConditions().getModifiedSince();
-        if( modificationDate != null )
+        Instant modifiedSince = request.getConditions().getModifiedSince().toInstant();
+        if( modifiedSince != null )
         {
-            EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
-            if( !lastModified.after( modificationDate ) )
+            if( !lastModified.isAfter( modifiedSince ) )
             {
                 throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
             }
         }
     }
+
+    private Instant cutoffMillis( long time )
+    {
+        return Instant.ofEpochMilli( time / 1000 * 1000 );
+    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index a5c0fa3..6d4af64 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -21,8 +21,14 @@ package org.apache.zest.library.rest.server.restlet.requestreader;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.Period;
+import java.time.ZonedDateTime;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Map;
 import java.util.function.Function;
 import org.apache.zest.api.association.AssociationDescriptor;
@@ -35,7 +41,6 @@ import org.apache.zest.api.property.PropertyDescriptor;
 import org.apache.zest.api.service.qualifier.Tagged;
 import org.apache.zest.api.structure.ModuleDescriptor;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
-import org.apache.zest.api.util.Dates;
 import org.apache.zest.api.value.ValueBuilder;
 import org.apache.zest.api.value.ValueBuilderFactory;
 import org.apache.zest.api.value.ValueComposite;
@@ -455,9 +460,33 @@ public class DefaultRequestReader
                     arg = Boolean.valueOf( argString );
                 }
             }
-            else if( Date.class.isAssignableFrom( parameterType ) )
+            else if( LocalDate.class.isAssignableFrom( parameterType ) )
             {
-                arg = Dates.fromString( argString );
+                arg = LocalDate.parse( argString );
+            }
+            else if( LocalDateTime.class.isAssignableFrom( parameterType ) )
+            {
+                arg = LocalDateTime.parse( argString );
+            }
+            else if( ZonedDateTime.class.isAssignableFrom( parameterType ) )
+            {
+                arg = ZonedDateTime.parse( argString );
+            }
+            else if( OffsetDateTime.class.isAssignableFrom( parameterType ) )
+            {
+                arg = OffsetDateTime.parse( argString );
+            }
+            else if( Instant.class.isAssignableFrom( parameterType ) )
+            {
+                arg = Instant.parse( argString );
+            }
+            else if( Duration.class.isAssignableFrom( parameterType ) )
+            {
+                arg = Duration.parse( argString );
+            }
+            else if( Period.class.isAssignableFrom( parameterType ) )
+            {
+                arg = Period.parse( argString );
             }
             else if( parameterType.isInterface() )
             {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
index 5f74b26..b33ae46 100644
--- a/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
+++ b/libraries/rest-server/src/main/java/org/apache/zest/library/rest/server/restlet/responsewriter/TableResponseWriter.java
@@ -24,20 +24,17 @@ import freemarker.template.Configuration;
 import freemarker.template.TemplateException;
 import java.io.IOException;
 import java.io.Writer;
-import java.text.SimpleDateFormat;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.json.JSONException;
-import org.json.JSONWriter;
 import org.apache.zest.api.injection.scope.Service;
-import org.apache.zest.api.util.Dates;
 import org.apache.zest.library.rest.common.table.Cell;
 import org.apache.zest.library.rest.common.table.Column;
 import org.apache.zest.library.rest.common.table.Row;
 import org.apache.zest.library.rest.common.table.Table;
+import org.json.JSONException;
+import org.json.JSONWriter;
 import org.restlet.Response;
 import org.restlet.data.CharacterSet;
 import org.restlet.data.MediaType;
@@ -129,21 +126,21 @@ public class TableResponseWriter extends AbstractResponseWriter
                                             .get()
                                             .equals( Table.DATETIME ) && value != null )
                                     {
-                                        value = Dates.toUtcString( (Date) value );
+                                        value = value.toString();
                                     }
                                     else if( columnList.get( idx )
                                                  .columnType()
                                                  .get()
                                                  .equals( Table.DATE ) && value != null )
                                     {
-                                        value = new SimpleDateFormat( "yyyy-MM-dd" ).format( (Date) value );
+                                        value = value.toString();
                                     }
                                     else if( columnList.get( idx )
                                                  .columnType()
                                                  .get()
                                                  .equals( Table.TIME_OF_DAY ) && value != null )
                                     {
-                                        value = new SimpleDateFormat( "HH:mm:ss" ).format( (Date) value );
+                                        value = value.toString();
                                     }
 
                                     if( value != null )

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
index 65fae4d..cff150b 100755
--- a/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/apache/zest/library/rest/admin/EntityResource.java
@@ -25,9 +25,9 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.Writer;
+import java.time.Instant;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Date;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -69,6 +69,8 @@ import org.restlet.representation.WriterRepresentation;
 import org.restlet.resource.ResourceException;
 import org.restlet.resource.ServerResource;
 
+import static java.time.Instant.ofEpochMilli;
+
 public class EntityResource
     extends ServerResource
 {
@@ -84,6 +86,7 @@ public class EntityResource
 
     @Uses
     private EntityStateSerializer entitySerializer;
+
     private String identity;
 
     public EntityResource()
@@ -140,10 +143,10 @@ public class EntityResource
             EntityState entityState = getEntityState( uow );
 
             // Check modification date
-            Date lastModified = getRequest().getConditions().getModifiedSince();
+            java.util.Date lastModified = getRequest().getConditions().getModifiedSince();
             if( lastModified != null )
             {
-                if( lastModified.getTime() / 1000 == entityState.lastModified() / 1000 )
+                if( lastModified.toInstant().getEpochSecond() == ofEpochMilli( entityState.lastModified()).getEpochSecond() )
                 {
                     throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
                 }
@@ -190,7 +193,7 @@ public class EntityResource
 
     private Representation entityHeaders( Representation representation, EntityState entityState )
     {
-        representation.setModificationDate( new Date( entityState.lastModified() ) );
+        representation.setModificationDate( new java.util.Date( entityState.lastModified() ) );
         representation.setTag( new Tag( "" + entityState.version() ) );
         representation.setCharacterSet( CharacterSet.UTF_8 );
         representation.setLanguages( Collections.singletonList( Language.ENGLISH ) );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
index dc7f925..0d4013d 100644
--- a/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
+++ b/libraries/rest/src/test/java/org/apache/zest/library/rest/admin/RestTest.java
@@ -57,8 +57,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
-public class RestTest
-    extends AbstractZestTest
+public class RestTest extends AbstractZestTest
 {
 
     @Override

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/dev-status.xml
----------------------------------------------------------------------
diff --git a/libraries/scheduler/dev-status.xml b/libraries/scheduler/dev-status.xml
index d43c910..55032e6 100644
--- a/libraries/scheduler/dev-status.xml
+++ b/libraries/scheduler/dev-status.xml
@@ -24,7 +24,7 @@
         http://zest.apache.org/schemas/2008/dev-status/1/dev-status.xsd">
   <status>
     <!--none,early,beta,stable,mature-->
-    <codebase>beta</codebase>
+    <codebase>early</codebase>
 
     <!-- none, brief, good, complete -->
     <documentation>good</documentation>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
index ceeac11..5270da0 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/CronSchedule.java
@@ -20,6 +20,7 @@
 package org.apache.zest.library.scheduler;
 
 import java.lang.annotation.Retention;
+import java.time.Instant;
 import org.apache.zest.api.constraint.Constraint;
 import org.apache.zest.api.constraint.ConstraintDeclaration;
 import org.apache.zest.api.constraint.Constraints;
@@ -75,16 +76,18 @@ public interface CronSchedule
         }
 
         @Override
-        public long nextRun( long from )
+        public Instant nextRun( Instant from )
         {
-            long actualFrom = from;
-            long firstRun = start().get().getMillis();
-            if( firstRun > from )
+            Instant actualFrom = from;
+            Instant firstRun = start().get();
+            if( firstRun.isAfter(from ))
             {
                 actualFrom = firstRun;
             }
             // TODO:PM cron "next run" handling mismatch with the underlying cron library
-            Long nextRun = createCron().firstRunAfter( actualFrom + 1000 );
+            Instant nextRun = Instant.ofEpochMilli(
+                createCron().firstRunAfter( actualFrom.plusSeconds( 1 ).toEpochMilli())
+            );
             LOGGER.info( "CronSchedule::nextRun({}) is {}", from, firstRun );
             return nextRun;
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
index 2fcc5c3..7421882 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/OnceSchedule.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler;
 
+import java.time.Instant;
 import org.apache.zest.api.mixin.Mixins;
 
 @Mixins( OnceSchedule.OnceScheduleMixin.class )
@@ -44,15 +45,15 @@ public interface OnceSchedule
         }
 
         @Override
-        public long nextRun( long from )
+        public Instant nextRun( Instant from )
         {
             if( done().get() )
             {
-                return Long.MIN_VALUE;
+                return Instant.MIN;
             }
             done().set( true );
-            long runAt = start().get().getMillis();
-            if( runAt >= from )
+            Instant runAt = start().get();
+            if( runAt.isAfter( from ) )
             {
                 return runAt;
             }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
index b9dae0f..6d7191d 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Schedule.java
@@ -19,13 +19,13 @@
  */
 package org.apache.zest.library.scheduler;
 
+import java.time.Instant;
+import java.time.ZonedDateTime;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.entity.EntityComposite;
 import org.apache.zest.api.property.Immutable;
 import org.apache.zest.api.property.Property;
-import org.apache.zest.library.scheduler.Task;
-import org.joda.time.DateTime;
 
 /**
  * Represent the scheduling of a {@link Task}.
@@ -42,7 +42,7 @@ public interface Schedule extends EntityComposite
      * @return The property containing the first time this Schedule will be run.
      */
     @Immutable
-    Property<DateTime> start();
+    Property<Instant> start();
 
     /** Returns true if the Schedule has been cancelled.
      *
@@ -120,7 +120,7 @@ public interface Schedule extends EntityComposite
      *
      * @return The exact absolute time when this Schedule is to be run next time, or -1 if never
      */
-    long nextRun( long from );
+    Instant nextRun( Instant from );
 
     /**
      * Return a representation of the Schedule in a human understandable format.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
index feba8c4..c5fdd81 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/ScheduleFactory.java
@@ -19,11 +19,12 @@
  */
 package org.apache.zest.library.scheduler;
 
+import java.time.Instant;
+import java.time.ZonedDateTime;
 import org.apache.zest.api.concern.Concerns;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
 import org.apache.zest.library.scheduler.defaults.DefaultScheduleFactoryMixin;
-import org.joda.time.DateTime;
 import org.apache.zest.api.mixin.Mixins;
 
 import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propagation.MANDATORY;
@@ -33,8 +34,8 @@ import static org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation.Propa
 public interface ScheduleFactory
 {
     @UnitOfWorkPropagation( MANDATORY)
-    Schedule newCronSchedule( Task task, String cronExpression, DateTime start );
+    Schedule newCronSchedule( Task task, String cronExpression, Instant start );
 
     @UnitOfWorkPropagation( MANDATORY)
-    Schedule newOnceSchedule( Task task, DateTime runAt );
+    Schedule newOnceSchedule( Task task, Instant runAt );
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
index 6699e44..ac081d6 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/Scheduler.java
@@ -19,8 +19,8 @@
  */
 package org.apache.zest.library.scheduler;
 
+import java.time.Instant;
 import org.apache.zest.library.scheduler.internal.Schedules;
-import org.joda.time.DateTime;
 import org.apache.zest.api.concern.Concerns;
 import org.apache.zest.api.structure.Application;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkConcern;
@@ -73,7 +73,7 @@ public interface Scheduler
      * @return The newly created Schedule
      */
     @UnitOfWorkPropagation( MANDATORY )
-    Schedule scheduleOnce( Task task, DateTime runAt );
+    Schedule scheduleOnce( Task task, Instant runAt );
 
     /**
      * Schedule a Task using a CronExpression.
@@ -108,7 +108,7 @@ public interface Scheduler
      * @return The newly created Schedule
      */
     @UnitOfWorkPropagation( MANDATORY )
-    Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, DateTime start );
+    Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start );
 
     /** Schedules a custom Schedule.
      *

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
index 73775c4..2d21e27 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/defaults/DefaultScheduleFactoryMixin.java
@@ -20,6 +20,7 @@
 
 package org.apache.zest.library.scheduler.defaults;
 
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
@@ -32,7 +33,6 @@ import org.apache.zest.library.scheduler.ScheduleFactory;
 import org.apache.zest.library.scheduler.SchedulerService;
 import org.apache.zest.library.scheduler.Task;
 import org.apache.zest.spi.uuid.UuidIdentityGeneratorService;
-import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,18 +51,18 @@ public class DefaultScheduleFactoryMixin
     private UuidIdentityGeneratorService uuid;
 
     @Override
-    public CronSchedule newCronSchedule( Task task, String cronExpression, DateTime start )
+    public CronSchedule newCronSchedule( Task task, String cronExpression, Instant start )
     {
         return newPersistentCronSchedule( task, cronExpression, start );
     }
 
     @Override
-    public Schedule newOnceSchedule( Task task, DateTime runAt )
+    public Schedule newOnceSchedule( Task task, Instant runAt )
     {
         return newPersistentOnceSchedule( task, runAt );
     }
 
-    private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
+    private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, Instant start )
     {
         UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
@@ -76,7 +76,7 @@ public class DefaultScheduleFactoryMixin
         return schedule;
     }
 
-    private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
+    private Schedule newPersistentOnceSchedule( Task task, Instant runAt )
     {
         UnitOfWork uow = uowf.currentUnitOfWork();
         EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
index 589a5a0..6ca01af 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/Execution.java
@@ -20,6 +20,8 @@
 
 package org.apache.zest.library.scheduler.internal;
 
+import java.time.Duration;
+import java.time.Instant;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -131,16 +133,14 @@ public interface Execution
 
         private boolean isTime( ScheduleTime scheduleTime )
         {
-            long now = System.currentTimeMillis();
-            return scheduleTime.nextTime() <= now;
+            return scheduleTime.nextTime().isBefore( Instant.now() );
         }
 
         private void waitFor( ScheduleTime scheduleTime )
             throws InterruptedException
         {
-            long now = System.currentTimeMillis();
-            long waitingTime = scheduleTime.nextTime() - now;
-            waitFor( waitingTime );
+            Duration waitingTime = Duration.between( Instant.now(), scheduleTime.nextTime() );
+            waitFor( waitingTime.toMillis() );
         }
 
         private void waitFor( long waitingTime )
@@ -164,14 +164,12 @@ public interface Execution
         @Override
         public void updateNextTime( ScheduleTime oldScheduleTime )
         {
-            long now = System.currentTimeMillis();
-
             try (UnitOfWork uow = uowf.newUnitOfWork()) // This will discard() the UoW when block is exited. We are only doing reads, so fine.
             {
                 submitTaskForExecution( oldScheduleTime );
                 Schedule schedule = uow.get( Schedule.class, oldScheduleTime.scheduleIdentity() );
-                long nextTime = schedule.nextRun( now );
-                if( nextTime != Long.MIN_VALUE )
+                Instant nextTime = schedule.nextRun( Instant.now() );
+                if( nextTime.isAfter( Instant.MIN ) )
                 {
                     ScheduleTime newScheduleTime = new ScheduleTime( oldScheduleTime.scheduleIdentity(), nextTime );
                     synchronized( lock )
@@ -205,15 +203,15 @@ public interface Execution
         @Override
         public void dispatchForExecution( Schedule schedule )
         {
-            long now = System.currentTimeMillis();
-            long nextRun = schedule.nextRun( now );
-            if( nextRun > 0 )
+            Instant nextRun = schedule.nextRun( Instant.now() );
+            if( nextRun.equals( Instant.MIN ) )
             {
-                synchronized( lock )
-                {
-                    timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
-                    lock.notifyAll();
-                }
+                return;
+            }
+            synchronized( lock )
+            {
+                timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
+                lock.notifyAll();
             }
         }
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
index 5236282..caf9a75 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/ScheduleTime.java
@@ -19,22 +19,23 @@
  */
 package org.apache.zest.library.scheduler.internal;
 
+import java.time.Instant;
 import org.apache.zest.api.util.NullArgumentException;
 
 public final class ScheduleTime
     implements Comparable<ScheduleTime>
 {
     private final String scheduleIdentity;
-    private final long nextTime;
+    private final Instant nextTime;
 
-    public ScheduleTime( String scheduleIdentity, long nextTime )
+    public ScheduleTime( String scheduleIdentity, Instant nextTime )
     {
         NullArgumentException.validateNotEmpty( "scheduleIdentity", scheduleIdentity );
         this.scheduleIdentity = scheduleIdentity;
         this.nextTime = nextTime;
     }
 
-    public long nextTime()
+    public Instant nextTime()
     {
         return nextTime;
     }
@@ -52,7 +53,7 @@ public final class ScheduleTime
             return 0;
         }
 
-        if( this.nextTime < another.nextTime )
+        if( this.nextTime.isBefore(another.nextTime) )
         {
             return -1;
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
index ab6ed40..43dc826 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/internal/SchedulerMixin.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler.internal;
 
+import java.time.Instant;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.Structure;
@@ -29,15 +30,14 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
 import org.apache.zest.api.unitofwork.UnitOfWorkFactory;
 import org.apache.zest.api.usecase.UsecaseBuilder;
+import org.apache.zest.library.scheduler.CronSchedule;
+import org.apache.zest.library.scheduler.Schedule;
+import org.apache.zest.library.scheduler.ScheduleFactory;
 import org.apache.zest.library.scheduler.Scheduler;
 import org.apache.zest.library.scheduler.SchedulerConfiguration;
 import org.apache.zest.library.scheduler.SchedulerService;
 import org.apache.zest.library.scheduler.SchedulesHandler;
 import org.apache.zest.library.scheduler.Task;
-import org.apache.zest.library.scheduler.CronSchedule;
-import org.apache.zest.library.scheduler.Schedule;
-import org.apache.zest.library.scheduler.ScheduleFactory;
-import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,21 +64,16 @@ public class SchedulerMixin
     @This
     private Configuration<SchedulerConfiguration> config;
 
-    public SchedulerMixin()
-    {
-    }
-
     @Override
     public Schedule scheduleOnce( Task task, int initialSecondsDelay )
     {
-        long now = System.currentTimeMillis();
-        Schedule schedule = scheduleFactory.newOnceSchedule( task, new DateTime( now + initialSecondsDelay * 1000 ) );
+        Schedule schedule = scheduleFactory.newOnceSchedule( task, Instant.now().plusSeconds( initialSecondsDelay ) );
         saveAndDispatch( schedule );
         return schedule;
     }
 
     @Override
-    public Schedule scheduleOnce( Task task, DateTime runAt )
+    public Schedule scheduleOnce( Task task, Instant runAt )
     {
         Schedule schedule = scheduleFactory.newOnceSchedule( task, runAt );
         saveAndDispatch( schedule );
@@ -88,14 +83,13 @@ public class SchedulerMixin
     @Override
     public Schedule scheduleCron( Task task, String cronExpression )
     {
-        DateTime now = new DateTime();
-        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, now );
+        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, Instant.now() );
         saveAndDispatch( schedule );
         return schedule;
     }
 
     @Override
-    public Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, DateTime start )
+    public Schedule scheduleCron( Task task, @CronSchedule.CronExpression String cronExpression, Instant start )
     {
         Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
         saveAndDispatch( schedule );
@@ -111,7 +105,7 @@ public class SchedulerMixin
     @Override
     public Schedule scheduleCron( Task task, String cronExpression, long initialDelay )
     {
-        DateTime start = new DateTime( System.currentTimeMillis() + initialDelay );
+        Instant start = Instant.now().plusMillis( initialDelay );
         Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start );
         saveAndDispatch( schedule );
         return schedule;
@@ -171,7 +165,8 @@ public class SchedulerMixin
             {
                 execution.dispatchForExecution( schedule );
             }
-        } catch( Exception e )
+        }
+        catch( Exception e )
         {
             e.printStackTrace();
         }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
index d708703..fac381d 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/Timeline.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.time.ZonedDateTime;
 import org.apache.zest.api.unitofwork.concern.UnitOfWorkPropagation;
 
@@ -69,6 +70,6 @@ public interface Timeline
      */
     @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
 // START SNIPPET: timeline
-    Iterable<TimelineRecord> getRecords( long from, long to );
+    Iterable<TimelineRecord> getRecords( Instant from, Instant to );
 }
 // END SNIPPET: timeline

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
index a35a6a8..6c50651 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineForScheduleConcern.java
@@ -22,6 +22,7 @@ package org.apache.zest.library.scheduler.timeline;
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.PrintStream;
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.concern.ConcernOf;
 import org.apache.zest.api.injection.scope.Structure;
@@ -71,7 +72,7 @@ public abstract class TimelineForScheduleConcern
         prototype.taskName().set( task().get().name().get() );
         List<String> tags = task().get().tags().get();
         prototype.taskTags().set( tags );
-        prototype.timestamp().set( System.currentTimeMillis() );
+        prototype.timestamp().set( Instant.now() );
         prototype.scheduleIdentity().set( this.identity().get() );
         prototype.details().set( details );
         TimelineRecord record = builder.newInstance();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
index 5bfd1d5..39108a9 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineRecord.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.util.List;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.entity.Queryable;
@@ -44,7 +45,7 @@ public interface TimelineRecord
     /**
      * @return Timestamp of this record
      */
-    Property<Long> timestamp();
+    Property<Instant> timestamp();
 
     /**
      * @return Name of the associated {@link org.apache.zest.library.scheduler.Task}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
index bf89862..9143bcf 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineScheduleMixin.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.util.Collection;
 import java.util.Collections;
@@ -64,7 +65,7 @@ public class TimelineScheduleMixin
     public Iterable<TimelineRecord> getNextRecords( int maxResults )
     {
         SortedSet<TimelineRecord> result = new TreeSet<>();
-        long time = System.currentTimeMillis();
+        Instant time = Instant.now();
         for( int i = 0; i < maxResults; i++ )
         {
             time = me.nextRun( time );
@@ -76,27 +77,27 @@ public class TimelineScheduleMixin
     @Override
     public Iterable<TimelineRecord> getRecords( ZonedDateTime from, ZonedDateTime to )
     {
-        return getRecords( from.toInstant().toEpochMilli(), to.toInstant().toEpochMilli() );
+        return getRecords( from.toInstant(), to.toInstant() );
     }
 
     @Override
-    public Iterable<TimelineRecord> getRecords( long from, long to )
+    public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
     {
-        long now = System.currentTimeMillis();
+        Instant now = Instant.now();
         SortedSet<TimelineRecord> result = new TreeSet<>();
         result.addAll( getPastRecords( from ) );
         result.addAll( getFutureRecords( now, to ) );
         return result;
     }
 
-    private Collection<? extends TimelineRecord> getPastRecords( long from )
+    private Collection<? extends TimelineRecord> getPastRecords( Instant from )
     {
         SortedSet<TimelineRecord> result = new TreeSet<>();
         List<TimelineRecord> timelineRecords = state.history().get();
         for( TimelineRecord record : timelineRecords )
         {
-            Long timestamp = record.timestamp().get();
-            if( timestamp >= from )
+            Instant timestamp = record.timestamp().get();
+            if( timestamp.isAfter( from ) )
             {
                 result.add( record );
             }
@@ -104,19 +105,19 @@ public class TimelineScheduleMixin
         return result;
     }
 
-    private Collection<? extends TimelineRecord> getFutureRecords( long now, long to )
+    private Collection<? extends TimelineRecord> getFutureRecords( Instant now, Instant to )
     {
-        if( now > to )
+        if( now.isAfter( to ) )
         {
             return Collections.emptyList();
         }
 
         SortedSet<TimelineRecord> result = new TreeSet<>();
-        long time = now;
-        while( time <= to )
+        Instant time = Instant.now();
+        while( time.isBefore(to) )
         {
             time = me.nextRun( time );
-            if( time <= to )
+            if( time.isBefore( to ) )
             {
                 result.add( createFutureRecord( time ) );
             }
@@ -124,7 +125,7 @@ public class TimelineScheduleMixin
         return result;
     }
 
-    private TimelineRecord createFutureRecord( long when )
+    private TimelineRecord createFutureRecord( Instant when )
     {
         ValueBuilder<TimelineRecord> builder = module.newValueBuilder( TimelineRecord.class );
         TimelineRecord prototype = builder.prototype();

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
index e4bc43d..41d5a98 100644
--- a/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
+++ b/libraries/scheduler/src/main/java/org/apache/zest/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
@@ -19,6 +19,7 @@
  */
 package org.apache.zest.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -93,7 +94,7 @@ public abstract class TimelineSchedulerServiceMixin
     }
 
     @Override
-    public Iterable<TimelineRecord> getRecords( long from, long to )
+    public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
     {
         SortedSet<TimelineRecord> result = new TreeSet<>();
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
index b62e552..a346f83 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/CronScheduleTest.java
@@ -20,16 +20,16 @@
 
 package org.apache.zest.library.scheduler;
 
+import java.time.Instant;
 import org.apache.zest.api.entity.EntityBuilder;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
-import org.joda.time.DateTime;
 import org.junit.Test;
 
-import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
 public class CronScheduleTest extends AbstractZestTest
@@ -53,16 +53,16 @@ public class CronScheduleTest extends AbstractZestTest
         builder1.instance().name().set( "abc" );
         Task task = builder1.newInstance();
         EntityBuilder<CronSchedule> builder = work.newEntityBuilder( CronSchedule.class );
-        builder.instance().start().set( DateTime.now() );
+        builder.instance().start().set( Instant.now() );
         builder.instance().task().set( task );
         builder.instance().cronExpression().set( "*/15 * * * * *" );
         CronSchedule schedule = builder.newInstance();
-        long nextRun = schedule.nextRun( System.currentTimeMillis() );
+        Instant nextRun = schedule.nextRun( Instant.now());
         for( int i = 0; i < 1000; i++ )
         {
-            long previousRun = nextRun;
+            Instant previousRun = nextRun;
             nextRun = schedule.nextRun( previousRun ); 
-            assertThat( "nextRun( previousRun + 1s ) @" + i, nextRun, is( previousRun + 15000 ) );
+            assertThat( "nextRun( previousRun + 1s ) @" + i, nextRun, equalTo( previousRun.plusSeconds( 15 )) );
         }
         work.discard();
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
index 38b41bf..9f3eae6 100644
--- a/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/apache/zest/library/scheduler/SchedulerTest.java
@@ -19,6 +19,8 @@
  */
 package org.apache.zest.library.scheduler;
 
+import java.time.Duration;
+import java.time.ZonedDateTime;
 import java.util.concurrent.Callable;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.unitofwork.UnitOfWork;
@@ -29,8 +31,6 @@ import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.library.scheduler.bootstrap.SchedulerAssembler;
 import org.apache.zest.library.scheduler.timeline.Timeline;
-import org.joda.time.DateTime;
-import org.joda.time.Interval;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -94,7 +94,7 @@ public class SchedulerTest
         throws UnitOfWorkCompletionException
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "TestMinutely" );
-        DateTime start = new DateTime();
+        ZonedDateTime start = ZonedDateTime.now();
         String taskIdentity;
         long sleepMillis;
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
@@ -104,13 +104,13 @@ public class SchedulerTest
             FooTask task = createFooTask( uow, usecase.name(), BAZAR );
             taskIdentity = task.identity().get();
 
-            DateTime expectedRun = start.withMillisOfSecond( 0 ).withSecondOfMinute( 0 ).plusMinutes( 1 );
+            ZonedDateTime expectedRun = start.withNano( 0 ).withSecond( 0 ).plusMinutes( 1 );
             scheduler.scheduleCron( task, "@minutely" );
 
             uow.complete();
 
-            sleepMillis = new Interval( start, expectedRun ).toDurationMillis();
-            LOGGER.info( "Task scheduled on {} to be run at {}", start.getMillis(), expectedRun.getMillis() );
+            sleepMillis = Duration.between( start, expectedRun ).toMillis();
+            LOGGER.info( "Task scheduled on {} to be run at {}", start.toLocalTime(), expectedRun.toLocalTime() );
         }
 
         await( usecase.name() )
@@ -121,22 +121,22 @@ public class SchedulerTest
         try( UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( usecase ) )
         {
             Timeline timeline = serviceFinder.findService( Timeline.class ).get();
-            DateTime now = new DateTime();
+            ZonedDateTime now =  ZonedDateTime.now();
 
             // Queries returning past records
             assertThat( count( timeline.getLastRecords( 5 ) ),
                         is( 2L ) );
-            assertThat( count( timeline.getRecords( start.getMillis(), now.getMillis() ) ),
+            assertThat( count( timeline.getRecords( start.toInstant(), now.toInstant() ) ),
                         is( 2L ) );
 
             // Queries returning future records
             assertThat( count( timeline.getNextRecords( 4 ) ),
                         is( 4L ) );
-            assertThat( count( timeline.getRecords( now.getMillis() + 100, now.plusMinutes( 5 ).getMillis() ) ),
+            assertThat( count( timeline.getRecords( now.plusNanos( 100000000L ), now.plusMinutes( 5 )) ),
                         is( 5L ) );
 
             // Queries returning mixed past and future records
-            assertThat( count( timeline.getRecords( start.getMillis(), now.plusMinutes( 5 ).getMillis() ) ),
+            assertThat( count( timeline.getRecords( start, now.plusMinutes( 5 ) ) ),
                         is( 7L ) );
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
index 820f2a6..77d93f6 100644
--- a/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
+++ b/manual/src/main/java/org/apache/zest/manual/recipes/createEntity/Accident.java
@@ -19,15 +19,15 @@
  */
 package org.apache.zest.manual.recipes.createEntity;
 
+import java.time.LocalDate;
 import org.apache.zest.api.property.Property;
-import java.util.Date;
 
 // START SNIPPET: entity
 public interface Accident
 {
     Property<String> description();
-    Property<Date> occured();
-    Property<Date> repaired();
+    Property<LocalDate> occured();
+    Property<LocalDate> repaired();
 }
 
 // END SNIPPET: entity
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
index 37abf10..f2a6adc 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/api/TransitEdge.java
@@ -20,7 +20,7 @@
 package org.apache.zest.sample.dcicargo.pathfinder_a.api;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.LocalDate;
 
 /**
  * Represents an edge in a path through a graph,
@@ -32,8 +32,8 @@ public final class TransitEdge implements Serializable
     private final String voyageNumber;
     private final String fromUnLocode;
     private final String toUnLocode;
-    private final Date fromDate;
-    private final Date toDate;
+    private final LocalDate fromDate;
+    private final LocalDate toDate;
 
     /**
      * Constructor.
@@ -47,8 +47,8 @@ public final class TransitEdge implements Serializable
     public TransitEdge( final String voyageNumber,
                         final String fromUnLocode,
                         final String toUnLocode,
-                        final Date fromDate,
-                        final Date toDate
+                        final LocalDate fromDate,
+                        final LocalDate toDate
     )
     {
         this.voyageNumber = voyageNumber;
@@ -73,12 +73,12 @@ public final class TransitEdge implements Serializable
         return toUnLocode;
     }
 
-    public Date getFromDate()
+    public LocalDate getFromDate()
     {
         return fromDate;
     }
 
-    public Date getToDate()
+    public LocalDate getToDate()
     {
         return toDate;
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/37910017/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
index f5540e8..8d6de22 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/apache/zest/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
@@ -19,9 +19,9 @@
  */
 package org.apache.zest.sample.dcicargo.pathfinder_a.internal;
 
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Random;
 import org.apache.zest.sample.dcicargo.pathfinder_a.api.GraphTraversalService;
@@ -33,8 +33,6 @@ public class GraphTraversalServiceImpl
 {
     private GraphDAO dao;
     private Random random;
-    private static final long ONE_MIN_MS = 1000 * 60;
-    private static final long ONE_DAY_MS = ONE_MIN_MS * 60 * 24;
 
     public GraphTraversalServiceImpl( GraphDAO dao )
     {
@@ -44,23 +42,23 @@ public class GraphTraversalServiceImpl
 
     public List<TransitPath> findShortestPath( String originUnLocode, String destinationUnLocode )
     {
-        Date date = nextDate( new Date() );
+        LocalDate date = nextDate( LocalDate.now());
 
         List<String> allVertices = dao.listLocations();
         allVertices.remove( originUnLocode );
         allVertices.remove( destinationUnLocode );
 
         final int candidateCount = getRandomNumberOfCandidates();
-        final List<TransitPath> candidates = new ArrayList<TransitPath>( candidateCount );
+        final List<TransitPath> candidates = new ArrayList<>( candidateCount );
 
         for( int i = 0; i < candidateCount; i++ )
         {
             allVertices = getRandomChunkOfLocations( allVertices );
-            final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>( allVertices.size() - 1 );
+            final List<TransitEdge> transitEdges = new ArrayList<>( allVertices.size() - 1 );
             final String firstLegTo = allVertices.get( 0 );
 
-            Date fromDate = nextDate( date );
-            Date toDate = nextDate( fromDate );
+            LocalDate fromDate = nextDate( date );
+            LocalDate toDate = nextDate( fromDate );
             date = nextDate( toDate );
 
             transitEdges.add( new TransitEdge(
@@ -90,9 +88,9 @@ public class GraphTraversalServiceImpl
         return candidates;
     }
 
-    private Date nextDate( Date date )
+    private LocalDate nextDate( LocalDate date )
     {
-        return new Date( date.getTime() + ONE_DAY_MS + ( random.nextInt( 1000 ) - 500 ) * ONE_MIN_MS );
+        return date.plusDays( 1 );
     }
 
     private int getRandomNumberOfCandidates()


Mime
View raw message