polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [34/50] [abbrv] zest-qi4j git commit: Replaced Joda Time with Java 8 Time API.
Date Fri, 17 Apr 2015 16:08:46 GMT
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/rest-common/src/main/java/org/qi4j/library/rest/common/table/TableBuilder.java
----------------------------------------------------------------------
diff --git a/libraries/rest-common/src/main/java/org/qi4j/library/rest/common/table/TableBuilder.java b/libraries/rest-common/src/main/java/org/qi4j/library/rest/common/table/TableBuilder.java
index 4f89795..9404166 100644
--- a/libraries/rest-common/src/main/java/org/qi4j/library/rest/common/table/TableBuilder.java
+++ b/libraries/rest-common/src/main/java/org/qi4j/library/rest/common/table/TableBuilder.java
@@ -17,14 +17,11 @@
 
 package org.qi4j.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.qi4j.api.util.Dates;
 import org.qi4j.api.value.ValueBuilder;
 import org.qi4j.api.value.ValueBuilderFactory;
 
@@ -35,191 +32,200 @@ 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 )
+                {
+                    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()
 //   {
@@ -270,33 +276,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-qi4j/blob/b71c878d/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/api/ResourceValidity.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/api/ResourceValidity.java b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/api/ResourceValidity.java
index 2715756..e16a8d6 100644
--- a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/api/ResourceValidity.java
+++ b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/api/ResourceValidity.java
@@ -63,7 +63,7 @@ public class ResourceValidity
         if( entity != null )
         {
             EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( state.lastModified() );
+            Date lastModified = new Date( state.lastModified().toEpochMilli() );
             Tag tag = new Tag( state.identity().identity() + "/" + state.version() );
             response.getEntity().setModificationDate( lastModified );
             response.getEntity().setTag( tag );
@@ -78,7 +78,7 @@ public class ResourceValidity
         if( modificationDate != null )
         {
             EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
+            Date lastModified = new Date( ( state.lastModified().toEpochMilli() / 1000 ) * 1000 ); // Cut off milliseconds
             if( lastModified.after( modificationDate ) )
             {
                 throw new ResourceException( Status.CLIENT_ERROR_CONFLICT );
@@ -90,7 +90,7 @@ public class ResourceValidity
         if( modificationDate != null )
         {
             EntityState state = spi.entityStateOf( entity );
-            Date lastModified = new Date( ( state.lastModified() / 1000 ) * 1000 ); // Cut off milliseconds
+            Date lastModified = new Date( ( state.lastModified().toEpochMilli() / 1000 ) * 1000 ); // Cut off milliseconds
             if( !lastModified.after( modificationDate ) )
             {
                 throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/requestreader/DefaultRequestReader.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/requestreader/DefaultRequestReader.java b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/requestreader/DefaultRequestReader.java
index ca63132..c29412e 100644
--- a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/requestreader/DefaultRequestReader.java
+++ b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/requestreader/DefaultRequestReader.java
@@ -2,8 +2,12 @@ package org.qi4j.library.rest.server.restlet.requestreader;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Map;
 import java.util.function.Function;
 import org.qi4j.api.association.AssociationDescriptor;
@@ -15,7 +19,6 @@ import org.qi4j.api.injection.scope.Structure;
 import org.qi4j.api.property.PropertyDescriptor;
 import org.qi4j.api.service.qualifier.Tagged;
 import org.qi4j.api.structure.Module;
-import org.qi4j.api.util.Dates;
 import org.qi4j.api.value.ValueBuilder;
 import org.qi4j.api.value.ValueComposite;
 import org.qi4j.api.value.ValueDeserializer;
@@ -446,9 +449,25 @@ 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( LocalTime.class.isAssignableFrom( parameterType ) )
+            {
+                arg = LocalTime.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( parameterType.isInterface() )
             {

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/responsewriter/TableResponseWriter.java
----------------------------------------------------------------------
diff --git a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/responsewriter/TableResponseWriter.java b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/responsewriter/TableResponseWriter.java
index 32ca740..8e300c6 100644
--- a/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/responsewriter/TableResponseWriter.java
+++ b/libraries/rest-server/src/main/java/org/qi4j/library/rest/server/restlet/responsewriter/TableResponseWriter.java
@@ -23,14 +23,12 @@ 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.qi4j.api.injection.scope.Service;
-import org.qi4j.api.util.Dates;
 import org.qi4j.library.rest.common.table.Cell;
 import org.qi4j.library.rest.common.table.Column;
 import org.qi4j.library.rest.common.table.Row;
@@ -126,21 +124,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-qi4j/blob/b71c878d/libraries/rest/src/main/java/org/qi4j/library/rest/admin/EntityResource.java
----------------------------------------------------------------------
diff --git a/libraries/rest/src/main/java/org/qi4j/library/rest/admin/EntityResource.java b/libraries/rest/src/main/java/org/qi4j/library/rest/admin/EntityResource.java
index 3474970..9ec95e3 100644
--- a/libraries/rest/src/main/java/org/qi4j/library/rest/admin/EntityResource.java
+++ b/libraries/rest/src/main/java/org/qi4j/library/rest/admin/EntityResource.java
@@ -22,6 +22,7 @@ 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;
@@ -107,7 +108,7 @@ public class EntityResource
         throws ResourceException
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "Remove entity" );
-        EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, module, System.currentTimeMillis() );
+        EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, module, Instant.now() );
         try
         {
             EntityReference identityRef = EntityReference.parseEntityReference( identity );
@@ -130,7 +131,7 @@ public class EntityResource
     {
         EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( UsecaseBuilder.newUsecase( "Get entity" ),
                                                                module,
-                                                               System.currentTimeMillis() );
+                                                               Instant.now() );
 
         try
         {
@@ -140,7 +141,7 @@ public class EntityResource
             Date lastModified = getRequest().getConditions().getModifiedSince();
             if( lastModified != null )
             {
-                if( lastModified.getTime() / 1000 == entityState.lastModified() / 1000 )
+                if( lastModified.getTime() / 1000 == entityState.lastModified().toEpochMilli() / 1000 )
                 {
                     throw new ResourceException( Status.REDIRECTION_NOT_MODIFIED );
                 }
@@ -187,7 +188,7 @@ public class EntityResource
 
     private Representation entityHeaders( Representation representation, EntityState entityState )
     {
-        representation.setModificationDate( new Date( entityState.lastModified() ) );
+        representation.setModificationDate( new Date( entityState.lastModified().toEpochMilli() ) );
         representation.setTag( new Tag( "" + entityState.version() ) );
         representation.setCharacterSet( CharacterSet.UTF_8 );
         representation.setLanguages( Collections.singletonList( Language.ENGLISH ) );
@@ -354,7 +355,7 @@ public class EntityResource
         throws ResourceException
     {
         Usecase usecase = UsecaseBuilder.newUsecase( "Update entity" );
-        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, module, System.currentTimeMillis() );
+        EntityStoreUnitOfWork unitOfWork = entityStore.newUnitOfWork( usecase, module, Instant.now() );
         EntityState entity = getEntityState( unitOfWork );
 
         Form form = new Form( entityRepresentation );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java
index 5052055..a6ad4e4 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/Scheduler.java
@@ -18,7 +18,7 @@
  */
 package org.qi4j.library.scheduler;
 
-import org.joda.time.DateTime;
+import java.time.Instant;
 import org.qi4j.api.concern.Concerns;
 import org.qi4j.api.structure.Application;
 import org.qi4j.api.unitofwork.concern.UnitOfWorkConcern;
@@ -67,7 +67,7 @@ public interface Scheduler
      * @return The newly created Schedule
      */
     @UnitOfWorkPropagation( MANDATORY )
-    Schedule scheduleOnce( Task task, DateTime runAt, boolean durable );
+    Schedule scheduleOnce( Task task, Instant runAt, boolean durable );
 
     /**
      * Schedule a Task using a CronExpression.
@@ -105,5 +105,5 @@ public interface Scheduler
      * @return The newly created Schedule
      */
     @UnitOfWorkPropagation( MANDATORY )
-    Schedule scheduleCron( Task task, @CronExpression String cronExpression, DateTime start, boolean durable );
+    Schedule scheduleCron( Task task, @CronExpression String cronExpression, Instant start, boolean durable );
 }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
index 9058f45..864658b 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/SchedulerMixin.java
@@ -18,6 +18,9 @@
  */
 package org.qi4j.library.scheduler;
 
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -28,7 +31,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import org.joda.time.DateTime;
 import org.qi4j.api.configuration.Configuration;
 import org.qi4j.api.injection.scope.Service;
 import org.qi4j.api.injection.scope.Structure;
@@ -84,7 +86,8 @@ public class SchedulerMixin
     public Schedule scheduleOnce( Task task, int initialSecondsDelay, boolean durable )
     {
         long now = System.currentTimeMillis();
-        Schedule schedule = scheduleFactory.newOnceSchedule( task, new DateTime( now + initialSecondsDelay * 1000 ), durable );
+        Schedule schedule = scheduleFactory.newOnceSchedule( task, Instant.now()
+            .plusSeconds( initialSecondsDelay ), durable );
         if( durable )
         {
             Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
@@ -95,7 +98,7 @@ public class SchedulerMixin
     }
 
     @Override
-    public Schedule scheduleOnce( Task task, DateTime runAt, boolean durable )
+    public Schedule scheduleOnce( Task task, Instant runAt, boolean durable )
     {
         Schedule schedule = scheduleFactory.newOnceSchedule( task, runAt, durable );
         dispatchForExecution( schedule );
@@ -110,8 +113,7 @@ public class SchedulerMixin
     @Override
     public Schedule scheduleCron( Task task, String cronExpression, boolean durable )
     {
-        DateTime now = new DateTime();
-        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, now, durable );
+        Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, Instant.now(), durable );
         if( durable )
         {
             Schedules schedules = module.currentUnitOfWork().get( Schedules.class, getSchedulesIdentity( me ) );
@@ -122,7 +124,7 @@ public class SchedulerMixin
     }
 
     @Override
-    public Schedule scheduleCron( Task task, @CronExpression String cronExpression, DateTime start, boolean durable )
+    public Schedule scheduleCron( Task task, @CronExpression String cronExpression, Instant start, boolean durable )
     {
         Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start, durable );
         if( durable )
@@ -137,7 +139,7 @@ public class SchedulerMixin
     @Override
     public Schedule scheduleCron( Task task, String cronExpression, long initialDelay, boolean durable )
     {
-        DateTime start = new DateTime( System.currentTimeMillis() + initialDelay );
+        Instant start = Instant.now().plusMillis( initialDelay );
         Schedule schedule = scheduleFactory.newCronSchedule( task, cronExpression, start, durable );
         if( durable )
         {
@@ -150,17 +152,16 @@ public class SchedulerMixin
 
     private void dispatchForExecution( Schedule schedule )
     {
-        long now = System.currentTimeMillis();
         synchronized( timingQueue )
         {
             if( timingQueue.size() == 0 )
             {
-                long nextRun = schedule.nextRun( now );
-                if( nextRun < 0 )
+                Instant nextRun = schedule.nextRun( Instant.now() );
+                if( nextRun.isBefore( Instant.now() ) )
                 {
                     return;
                 }
-                System.out.println( "Next run at: " + new DateTime( nextRun ) );
+                System.out.println( "Next run at: " + nextRun.atOffset( ZoneOffset.UTC ) );
                 timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
                 if( scheduleHandler == null )
                 {
@@ -170,12 +171,12 @@ public class SchedulerMixin
             else
             {
                 ScheduleTime first = timingQueue.first();
-                long nextRun = schedule.nextRun( now );
-                if( nextRun < 0 )
+                Instant nextRun = schedule.nextRun( Instant.now() );
+                if( nextRun.isBefore( Instant.now() ) )
                 {
                     return;
                 }
-                System.out.println( "Next run at: " + new DateTime( nextRun ) );
+                System.out.println( "Next run at: " + nextRun.atOffset( ZoneOffset.UTC ) );
                 timingQueue.add( new ScheduleTime( schedule.identity().get(), nextRun ) );
                 ScheduleTime newFirst = timingQueue.first();
                 if( !first.equals( newFirst ) )
@@ -192,7 +193,8 @@ public class SchedulerMixin
     private void dispatchHandler()
     {
         scheduleHandler = new ScheduleHandler();
-        managementExecutor.schedule( scheduleHandler, timingQueue.first().nextTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS );
+        long delay = Instant.now().until( timingQueue.first().nextTime, ChronoUnit.MILLIS );
+        managementExecutor.schedule( scheduleHandler, delay, TimeUnit.MILLISECONDS );
     }
 
     @Override
@@ -296,7 +298,7 @@ public class SchedulerMixin
                 else
                 {
                     ScheduleTime nextTime = timingQueue.first();
-                    future = managementExecutor.schedule( scheduleHandler, nextTime.nextTime, TimeUnit.MILLISECONDS );
+                    future = managementExecutor.schedule( scheduleHandler, nextTime.nextTime.toEpochMilli(), TimeUnit.MILLISECONDS );
                 }
             }
         }
@@ -357,5 +359,4 @@ public class SchedulerMixin
             }
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
index 5fba485..e4f8cc2 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/Schedule.java
@@ -18,7 +18,7 @@
  */
 package org.qi4j.library.scheduler.schedule;
 
-import org.joda.time.DateTime;
+import java.time.Instant;
 import org.qi4j.api.association.Association;
 import org.qi4j.api.entity.Identity;
 import org.qi4j.api.property.Immutable;
@@ -41,7 +41,7 @@ public interface Schedule
      * @return The property containing the first time this Schedule will be run.
      */
     @Immutable
-    Property<DateTime> start();
+    Property<Instant> start();
 
     /**
      * Called just before the {@link org.qi4j.library.scheduler.Task#run()} method is called.
@@ -73,7 +73,7 @@ public interface Schedule
      *
      * @return The exact absolute time when this Schedule is to be run next time.
      */
-    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-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java
index 7f5b88c..b9b777b 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleFactory.java
@@ -15,7 +15,7 @@
  */
 package org.qi4j.library.scheduler.schedule;
 
-import org.joda.time.DateTime;
+import java.time.Instant;
 import org.qi4j.api.entity.EntityBuilder;
 import org.qi4j.api.injection.scope.Service;
 import org.qi4j.api.injection.scope.Structure;
@@ -33,9 +33,9 @@ import org.slf4j.LoggerFactory;
 @Mixins( ScheduleFactory.Mixin.class )
 public interface ScheduleFactory
 {
-    Schedule newCronSchedule( Task task, String cronExpression, DateTime start, boolean durable );
+    Schedule newCronSchedule( Task task, String cronExpression, Instant start, boolean durable );
 
-    Schedule newOnceSchedule( Task task, DateTime runAt, boolean durable );
+    Schedule newOnceSchedule( Task task, Instant runAt, boolean durable );
 
     class Mixin
         implements ScheduleFactory
@@ -49,7 +49,7 @@ public interface ScheduleFactory
         private SchedulerService scheduler;
 
         @Override
-        public CronSchedule newCronSchedule( Task task, String cronExpression, DateTime start, boolean durable )
+        public CronSchedule newCronSchedule( Task task, String cronExpression, Instant start, boolean durable )
         {
             if( durable )
             {
@@ -59,7 +59,7 @@ public interface ScheduleFactory
         }
 
         @Override
-        public Schedule newOnceSchedule( Task task, DateTime runAt, boolean durable )
+        public Schedule newOnceSchedule( Task task, Instant runAt, boolean durable )
         {
             if( durable )
             {
@@ -68,7 +68,7 @@ public interface ScheduleFactory
             return newTransientOnceSchedule( task, runAt );
         }
 
-        private CronSchedule newTransientCronSchedule( Task task, String cronExpression, DateTime start )
+        private CronSchedule newTransientCronSchedule( Task task, String cronExpression, Instant start )
         {
             ValueBuilder<CronSchedule> builder = module.newValueBuilder( CronSchedule.class );
             CronSchedule prototype = builder.prototype();
@@ -80,7 +80,7 @@ public interface ScheduleFactory
             return schedule;
         }
 
-        private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
+        private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, Instant start )
         {
             UnitOfWork uow = module.currentUnitOfWork();
             EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
@@ -93,7 +93,7 @@ public interface ScheduleFactory
             return schedule;
         }
 
-        private Schedule newTransientOnceSchedule( Task task, DateTime runAt )
+        private Schedule newTransientOnceSchedule( Task task, Instant runAt )
         {
             ValueBuilder<OnceSchedule> builder = module.newValueBuilder( OnceSchedule.class );
             OnceSchedule builderInstance = builder.prototype();
@@ -104,7 +104,7 @@ public interface ScheduleFactory
             return schedule;
         }
 
-        private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
+        private Schedule newPersistentOnceSchedule( Task task, Instant runAt )
         {
             UnitOfWork uow = module.currentUnitOfWork();
             EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java
index 7bf07d9..01de000 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/ScheduleTime.java
@@ -16,13 +16,15 @@
  */
 package org.qi4j.library.scheduler.schedule;
 
+import java.time.Instant;
+
 public final class ScheduleTime
     implements Comparable<ScheduleTime>
 {
     public String scheduleIdentity;
-    public long nextTime;
+    public Instant nextTime;
 
-    public ScheduleTime( String scheduleIdentity, long nextTime )
+    public ScheduleTime( String scheduleIdentity, Instant nextTime )
     {
         if( scheduleIdentity == null )
         {
@@ -43,38 +45,45 @@ public final class ScheduleTime
         {
             return false;
         }
+
         ScheduleTime that = (ScheduleTime) o;
-        if( nextTime != that.nextTime )
+
+        if( nextTime != null ? !nextTime.equals( that.nextTime ) : that.nextTime != null )
+        {
+            return false;
+        }
+        if( !scheduleIdentity.equals( that.scheduleIdentity ) )
         {
             return false;
         }
-        return scheduleIdentity.equals( that.scheduleIdentity );
+
+        return true;
     }
 
     @Override
     public int hashCode()
     {
         int result = scheduleIdentity.hashCode();
-        result = 31 * result + (int) ( nextTime ^ ( nextTime >>> 32 ) );
+        result = 31 * result + ( nextTime != null ? nextTime.hashCode() : 0 );
         return result;
     }
 
     @Override
     public int compareTo( ScheduleTime another )
     {
-        if( this.nextTime < another.nextTime )
+        if( this.nextTime.isBefore( another.nextTime ) )
         {
             return -1;
         }
         else
         {
-            if( this.nextTime == another.nextTime )
+            if( this.nextTime.isAfter( another.nextTime ) )
             {
-                return 0;
+                return 1;
             }
             else
             {
-                return 1;
+                return 0;
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
index a1645bf..e8baff5 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/cron/CronSchedule.java
@@ -16,6 +16,7 @@
  */
 package org.qi4j.library.scheduler.schedule.cron;
 
+import java.time.Instant;
 import org.qi4j.api.mixin.Mixins;
 import org.qi4j.api.property.Immutable;
 import org.qi4j.api.property.Property;
@@ -76,16 +77,15 @@ public interface CronSchedule
         }
 
         @Override
-        public long nextRun( long from )
+        public Instant nextRun( Instant from )
         {
-            long firstRun = start().get().getMillis();
-            if( firstRun > from )
+            if( start().get().isAfter( from ) )
             {
-                from = firstRun;
+                from = start().get();
             }
-            Long nextRun = new org.codeartisans.sked.cron.CronSchedule( cronExpression().get() ).firstRunAfter( from );
-            LOGGER.info( "Schedule.firstRunAfter({}) CronSchedule result is {}", from, firstRun );
-            return nextRun;
+            Long nextRun = new org.codeartisans.sked.cron.CronSchedule( cronExpression().get() ).firstRunAfter( from.toEpochMilli() );
+            LOGGER.info( "Schedule.firstRunAfter({}) CronSchedule result is {}", from, nextRun );
+            return Instant.ofEpochMilli( nextRun );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java
index 637e3d2..0a98b1c 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/schedule/once/OnceSchedule.java
@@ -16,6 +16,7 @@
  */
 package org.qi4j.library.scheduler.schedule.once;
 
+import java.time.Instant;
 import org.qi4j.api.mixin.Mixins;
 import org.qi4j.library.scheduler.schedule.Schedule;
 
@@ -53,14 +54,13 @@ public interface OnceSchedule
         }
 
         @Override
-        public long nextRun( long from )
+        public Instant nextRun( Instant from )
         {
-            long runAt = start().get().getMillis();
-            if( runAt >= from )
+            if( ! start().get().isBefore(from) )
             {
-                return runAt;
+                return start().get();
             }
-            return -1;
+            return Instant.MIN;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java
index 9c77162..bb79057 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/Timeline.java
@@ -18,7 +18,7 @@
  */
 package org.qi4j.library.scheduler.timeline;
 
-import org.joda.time.DateTime;
+import java.time.Instant;
 import org.qi4j.api.unitofwork.concern.UnitOfWorkPropagation;
 
 /**
@@ -57,17 +57,6 @@ public interface Timeline
      */
     @UnitOfWorkPropagation( UnitOfWorkPropagation.Propagation.MANDATORY )
 // START SNIPPET: timeline
-    Iterable<TimelineRecord> getRecords( DateTime from, DateTime to );
-// END SNIPPET: timeline
-
-    /**
-     * @param from Lower limit
-     * @param to   Upper limit
-     *
-     * @return Records between the given dates
-     */
-    @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-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java
index 60bedba..6165bdd 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineForScheduleConcern.java
@@ -20,6 +20,7 @@ package org.qi4j.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.qi4j.api.concern.ConcernOf;
 import org.qi4j.api.injection.scope.Structure;
@@ -69,7 +70,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-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java
index f4ac63f..fc3ae61 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineRecord.java
@@ -18,6 +18,7 @@
  */
 package org.qi4j.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.util.List;
 import org.qi4j.api.common.UseDefaults;
 import org.qi4j.api.entity.Queryable;
@@ -43,7 +44,7 @@ public interface TimelineRecord
     /**
      * @return Timestamp of this record
      */
-    Property<Long> timestamp();
+    Property<Instant> timestamp();
 
     /**
      * @return Name of the associated {@link org.qi4j.library.scheduler.Task}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java
index eb91f1c..38a6978 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineScheduleMixin.java
@@ -15,12 +15,12 @@
  */
 package org.qi4j.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import org.joda.time.DateTime;
 import org.qi4j.api.injection.scope.Structure;
 import org.qi4j.api.injection.scope.This;
 import org.qi4j.api.structure.Module;
@@ -60,7 +60,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 );
@@ -70,29 +70,23 @@ public class TimelineScheduleMixin
     }
 
     @Override
-    public Iterable<TimelineRecord> getRecords( DateTime from, DateTime to )
+    public Iterable<TimelineRecord> getRecords( Instant from, Instant to )
     {
-        return getRecords( from.getMillis(), to.getMillis() );
-    }
-
-    @Override
-    public Iterable<TimelineRecord> getRecords( long from, long 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.isBefore(from) )
             {
                 result.add( record );
             }
@@ -100,19 +94,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 = now;
+        while( ! time.isAfter(to) )
         {
             time = me.nextRun( time );
-            if( time <= to )
+            if( ! time.isAfter(to) )
             {
                 result.add( createFutureRecord( time ) );
             }
@@ -120,7 +114,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-qi4j/blob/b71c878d/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
index 8a55520..24fa33a 100644
--- a/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
+++ b/libraries/scheduler/src/main/java/org/qi4j/library/scheduler/timeline/TimelineSchedulerServiceMixin.java
@@ -15,9 +15,9 @@
  */
 package org.qi4j.library.scheduler.timeline;
 
+import java.time.Instant;
 import java.util.SortedSet;
 import java.util.TreeSet;
-import org.joda.time.DateTime;
 import org.qi4j.api.injection.scope.Service;
 import org.qi4j.api.injection.scope.Structure;
 import org.qi4j.api.service.ServiceComposite;
@@ -76,24 +76,7 @@ public abstract class TimelineSchedulerServiceMixin
     }
 
     @Override
-    public Iterable<TimelineRecord> getRecords( DateTime from, DateTime to )
-    {
-        SortedSet<TimelineRecord> result = new TreeSet<>();
-
-        UnitOfWork uow = module.currentUnitOfWork();
-        String schedulesName = SchedulerMixin.getSchedulesIdentity( scheduler );
-        Schedules schedules = uow.get( Schedules.class, schedulesName );
-        for( Schedule schedule : schedules.schedules() )
-        {
-            Timeline timeline = (Timeline) schedule;
-            Iterable<TimelineRecord> lastRecords = timeline.getRecords( from, to );
-            Iterables.addAll( result, lastRecords );
-        }
-        return result;
-    }
-
-    @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-qi4j/blob/b71c878d/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/SchedulerTest.java
----------------------------------------------------------------------
diff --git a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/SchedulerTest.java b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/SchedulerTest.java
index ac38d8e..4228c19 100644
--- a/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/SchedulerTest.java
+++ b/libraries/scheduler/src/test/java/org/qi4j/library/scheduler/SchedulerTest.java
@@ -18,9 +18,10 @@
  */
 package org.qi4j.library.scheduler;
 
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoUnit;
 import java.util.concurrent.Callable;
-import org.joda.time.DateTime;
-import org.joda.time.Interval;
 import org.junit.Test;
 import org.qi4j.api.common.Visibility;
 import org.qi4j.api.unitofwork.UnitOfWork;
@@ -87,7 +88,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 = module.newUnitOfWork( usecase ) )
@@ -97,13 +98,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", true );
 
             uow.complete();
 
-            sleepMillis = new Interval( start, expectedRun ).toDurationMillis();
-            LOGGER.info( "Task scheduled on {} to be run at {}", start.getMillis(), expectedRun.getMillis() );
+            sleepMillis = start.until(expectedRun, ChronoUnit.MILLIS);
+            LOGGER.info( "Task scheduled on {} to be run at {}", start, expectedRun );
         }
 
         await( usecase.name() ).
@@ -113,22 +114,22 @@ public class SchedulerTest
         try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
         {
             Timeline timeline = module.findService( Timeline.class ).get();
-            DateTime now = new DateTime();
 
             // Queries returning past records
             assertThat( count( timeline.getLastRecords( 5 ) ),
                         is( 2L ) );
-            assertThat( count( timeline.getRecords( start.getMillis(), now.getMillis() ) ),
+            Instant now = Instant.now();
+            assertThat( count( timeline.getRecords( start.toInstant(), now ) ),
                         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.plusMillis( 100 ), now.plusSeconds( 300 ) ) ),
                         is( 5L ) );
 
             // Queries returning mixed past and future records
-            assertThat( count( timeline.getRecords( start.getMillis(), now.plusMinutes( 5 ).getMillis() ) ),
+            assertThat( count( timeline.getRecords( start.toInstant(), now.plusSeconds( 300 ) ) ),
                         is( 7L ) );
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/manual/src/main/java/org/qi4j/manual/recipes/createEntity/Accident.java
----------------------------------------------------------------------
diff --git a/manual/src/main/java/org/qi4j/manual/recipes/createEntity/Accident.java b/manual/src/main/java/org/qi4j/manual/recipes/createEntity/Accident.java
index 8276510..f36f185 100644
--- a/manual/src/main/java/org/qi4j/manual/recipes/createEntity/Accident.java
+++ b/manual/src/main/java/org/qi4j/manual/recipes/createEntity/Accident.java
@@ -1,14 +1,14 @@
 package org.qi4j.manual.recipes.createEntity;
 
+import java.time.ZonedDateTime;
 import org.qi4j.api.property.Property;
-import java.util.Date;
 
 // START SNIPPET: entity
 public interface Accident
 {
     Property<String> description();
-    Property<Date> occured();
-    Property<Date> repaired();
+    Property<ZonedDateTime> occured();
+    Property<ZonedDateTime> repaired();
 }
 
 // END SNIPPET: entity
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/api/TransitEdge.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/api/TransitEdge.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/api/TransitEdge.java
index 51315de..f85e028 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/api/TransitEdge.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/api/TransitEdge.java
@@ -18,7 +18,7 @@
 package org.qi4j.sample.dcicargo.pathfinder_a.api;
 
 import java.io.Serializable;
-import java.util.Date;
+import java.time.ZonedDateTime;
 
 /**
  * Represents an edge in a path through a graph,
@@ -30,8 +30,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 ZonedDateTime fromDate;
+    private final ZonedDateTime toDate;
 
     /**
      * Constructor.
@@ -45,8 +45,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 ZonedDateTime fromDate,
+                        final ZonedDateTime toDate
     )
     {
         this.voyageNumber = voyageNumber;
@@ -71,12 +71,12 @@ public final class TransitEdge implements Serializable
         return toUnLocode;
     }
 
-    public Date getFromDate()
+    public ZonedDateTime getFromDate()
     {
         return fromDate;
     }
 
-    public Date getToDate()
+    public ZonedDateTime getToDate()
     {
         return toDate;
     }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
index 41237c6..e5f92d6 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/pathfinder_a/internal/GraphTraversalServiceImpl.java
@@ -17,9 +17,9 @@
  */
 package org.qi4j.sample.dcicargo.pathfinder_a.internal;
 
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Date;
 import java.util.List;
 import java.util.Random;
 import org.qi4j.sample.dcicargo.pathfinder_a.api.GraphTraversalService;
@@ -42,7 +42,7 @@ public class GraphTraversalServiceImpl
 
     public List<TransitPath> findShortestPath( String originUnLocode, String destinationUnLocode )
     {
-        Date date = nextDate( new Date() );
+        ZonedDateTime date = nextDate( ZonedDateTime.now() );
 
         List<String> allVertices = dao.listLocations();
         allVertices.remove( originUnLocode );
@@ -57,8 +57,8 @@ public class GraphTraversalServiceImpl
             final List<TransitEdge> transitEdges = new ArrayList<TransitEdge>( allVertices.size() - 1 );
             final String firstLegTo = allVertices.get( 0 );
 
-            Date fromDate = nextDate( date );
-            Date toDate = nextDate( fromDate );
+            ZonedDateTime fromDate = nextDate( date );
+            ZonedDateTime toDate = nextDate( fromDate );
             date = nextDate( toDate );
 
             transitEdges.add( new TransitEdge(
@@ -88,9 +88,9 @@ public class GraphTraversalServiceImpl
         return candidates;
     }
 
-    private Date nextDate( Date date )
+    private ZonedDateTime nextDate( ZonedDateTime date )
     {
-        return new Date( date.getTime() + ONE_DAY_MS + ( random.nextInt( 1000 ) - 500 ) * ONE_MIN_MS );
+        return date.plusDays( 1 + random.nextInt(30) );
     }
 
     private int getRandomNumberOfCandidates()

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java
index 690261d..70f61ba 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/DCISampleApplication_a.java
@@ -17,7 +17,6 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.bootstrap;
 
-import java.util.Date;
 import org.apache.wicket.ConverterLocator;
 import org.apache.wicket.Page;
 import org.apache.wicket.datetime.PatternDateConverter;
@@ -53,9 +52,6 @@ public class DCISampleApplication_a
 
         // Show/hide wicket tags in html code
         getMarkupSettings().setStripWicketTags( true );
-
-        // Default date format (we don't care for now about the hour of the day)
-        ( (ConverterLocator) getConverterLocator() ).set( Date.class, new PatternDateConverter( "yyyy-MM-dd", true ) );
     }
 
     private void mountPages()

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
index ac474a6..a46a8c5 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseData.java
@@ -17,12 +17,10 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.bootstrap.sampledata;
 
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
-import org.joda.time.DateTime;
-import org.joda.time.LocalDate;
 import org.qi4j.api.structure.Module;
 import org.qi4j.api.value.ValueBuilder;
 import org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification;
@@ -39,6 +37,8 @@ import org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage;
  */
 public abstract class BaseData
 {
+    private static final ZonedDateTime TODAY = ZonedDateTime.now().withHour( 0 ).withMinute( 0 ).withSecond( 0 );
+
     protected Module module;
 
     protected static UnLocode AUMEL;
@@ -67,7 +67,11 @@ public abstract class BaseData
         return unlocode.newInstance();
     }
 
-    protected CarrierMovement carrierMovement( Location depLoc, Location arrLoc, Date depTime, Date arrTime )
+    protected CarrierMovement carrierMovement( Location depLoc,
+                                               Location arrLoc,
+                                               ZonedDateTime depTime,
+                                               ZonedDateTime arrTime
+    )
     {
         ValueBuilder<CarrierMovement> carrierMovement = module.newValueBuilder( CarrierMovement.class );
         carrierMovement.prototype().departureLocation().set( depLoc );
@@ -86,7 +90,7 @@ public abstract class BaseData
         return schedule.newInstance();
     }
 
-    protected Leg leg( Voyage voyage, Location load, Location unload, Date loadTime, Date unloadTime )
+    protected Leg leg( Voyage voyage, Location load, Location unload, ZonedDateTime loadTime, ZonedDateTime unloadTime )
     {
         ValueBuilder<Leg> leg = module.newValueBuilder( Leg.class );
         leg.prototype().voyage().set( voyage );
@@ -106,7 +110,7 @@ public abstract class BaseData
         return itinerary.newInstance();
     }
 
-    protected RouteSpecification routeSpecification( Location origin, Location destination, Date deadline )
+    protected RouteSpecification routeSpecification( Location origin, Location destination, ZonedDateTime deadline )
     {
         ValueBuilder<RouteSpecification> routeSpec = module.newValueBuilder( RouteSpecification.class );
         routeSpec.prototype().origin().set( origin );
@@ -115,8 +119,8 @@ public abstract class BaseData
         return routeSpec.newInstance();
     }
 
-    protected static Date day( int days )
+    protected static ZonedDateTime day( int days )
     {
-        return LocalDate.now().plusDays( days ).toDate();
+        return TODAY.plusDays( days );
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
index 116b733..9178997 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/BaseDataService.java
@@ -26,9 +26,7 @@ import org.qi4j.api.service.ServiceComposite;
 import org.qi4j.api.service.ServiceReference;
 import org.qi4j.api.structure.Module;
 import org.qi4j.api.unitofwork.UnitOfWork;
-import org.qi4j.api.unitofwork.UnitOfWorkFactory;
 import org.qi4j.api.value.ValueBuilder;
-import org.qi4j.api.value.ValueBuilderFactory;
 import org.qi4j.sample.dcicargo.sample_a.data.entity.CargosEntity;
 import org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity;
 import org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location;
@@ -44,26 +42,25 @@ import static org.qi4j.api.usecase.UsecaseBuilder.newUsecase;
 /**
  * Create basic sample data
  */
-@Mixins( BaseDataService.Mixin.class )
-@Activators( BaseDataService.Activator.class )
+@Mixins(BaseDataService.Mixin.class)
+@Activators(BaseDataService.Activator.class)
 public interface BaseDataService
     extends ServiceComposite
 {
 
-    void createBaseData() 
-    		throws Exception;
+    void createBaseData()
+        throws Exception;
 
     class Activator
-            extends ActivatorAdapter<ServiceReference<BaseDataService>>
+        extends ActivatorAdapter<ServiceReference<BaseDataService>>
     {
 
         @Override
         public void afterActivation( ServiceReference<BaseDataService> activated )
-                throws Exception
+            throws Exception
         {
             activated.get().createBaseData();
         }
-
     }
 
     public abstract class Mixin extends BaseData
@@ -78,28 +75,28 @@ public interface BaseDataService
 
         @Override
         public void createBaseData()
-        	throws Exception
+            throws Exception
         {
             logger.debug( "CREATING BASIC DATA..." );
             UnitOfWork uow = module.newUnitOfWork( newUsecase( "Open uow for " ) );
             try
             {
-	            // UnLocode value objects
-	            AUMEL = unlocode( "AUMEL" ); // Melbourne
-	            CNHGH = unlocode( "CNHGH" ); // Hangzou
-	            CNHKG = unlocode( "CNHKG" ); // Hong Kong
-	            CNSHA = unlocode( "CNSHA" ); // Shanghai
-	            DEHAM = unlocode( "DEHAM" ); // Hamburg
-	            FIHEL = unlocode( "FIHEL" ); // Helsinki
-	            JNTKO = unlocode( "JNTKO" ); // Tokyo
-	            NLRTM = unlocode( "NLRTM" ); // Rotterdam
-	            SEGOT = unlocode( "SEGOT" ); // Gothenburg
-	            SESTO = unlocode( "SESTO" ); // Stockholm
-	            USCHI = unlocode( "USCHI" ); // Chicago
-	            USDAL = unlocode( "USDAL" ); // Dallas
-	            USNYC = unlocode( "USNYC" ); // New York
-	
-	            // Location entity objects
+                // UnLocode value objects
+                AUMEL = unlocode( "AUMEL" ); // Melbourne
+                CNHGH = unlocode( "CNHGH" ); // Hangzou
+                CNHKG = unlocode( "CNHKG" ); // Hong Kong
+                CNSHA = unlocode( "CNSHA" ); // Shanghai
+                DEHAM = unlocode( "DEHAM" ); // Hamburg
+                FIHEL = unlocode( "FIHEL" ); // Helsinki
+                JNTKO = unlocode( "JNTKO" ); // Tokyo
+                NLRTM = unlocode( "NLRTM" ); // Rotterdam
+                SEGOT = unlocode( "SEGOT" ); // Gothenburg
+                SESTO = unlocode( "SESTO" ); // Stockholm
+                USCHI = unlocode( "USCHI" ); // Chicago
+                USDAL = unlocode( "USDAL" ); // Dallas
+                USNYC = unlocode( "USNYC" ); // New York
+
+                // Location entity objects
                 Location MELBOURNE = location( AUMEL, "Melbourne" );
                 Location HANGZHOU = location( CNHGH, "Hangzhou" );
                 Location HONGKONG = location( CNHKG, "Hongkong" );
@@ -114,43 +111,43 @@ public interface BaseDataService
                 Location DALLAS = location( USDAL, "Dallas" );
                 Location NEWYORK = location( USNYC, "New York" );
 
-	            // Voyage entity objects
+                // Voyage entity objects
                 Voyage V100S = voyage( "V100S", schedule(
-	                carrierMovement( NEWYORK, CHICAGO, day( 1 ), day( 2 ) ),
-	                carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
-	            ) );
+                    carrierMovement( NEWYORK, CHICAGO, day( 1 ), day( 2 ) ),
+                    carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
+                ) );
                 Voyage V200T = voyage( "V200T", schedule(
-	                carrierMovement( NEWYORK, CHICAGO, day( 7 ), day( 8 ) ),
-	                carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
-	            ) );
+                    carrierMovement( NEWYORK, CHICAGO, day( 7 ), day( 8 ) ),
+                    carrierMovement( CHICAGO, DALLAS, day( 8 ), day( 9 ) )
+                ) );
                 Voyage V300A = voyage( "V300A", schedule(
-	                carrierMovement( DALLAS, HAMBURG, day( 10 ), day( 14 ) ),
-	                carrierMovement( HAMBURG, STOCKHOLM, day( 15 ), day( 16 ) ),
-	                carrierMovement( STOCKHOLM, HELSINKI, day( 17 ), day( 18 ) )
-	            ) );
+                    carrierMovement( DALLAS, HAMBURG, day( 10 ), day( 14 ) ),
+                    carrierMovement( HAMBURG, STOCKHOLM, day( 15 ), day( 16 ) ),
+                    carrierMovement( STOCKHOLM, HELSINKI, day( 17 ), day( 18 ) )
+                ) );
                 Voyage V400S = voyage( "V400S", schedule(
-	                carrierMovement( TOKYO, ROTTERDAM, day( 9 ), day( 15 ) ),
-	                carrierMovement( ROTTERDAM, HAMBURG, day( 15 ), day( 16 ) ),
-	                carrierMovement( HAMBURG, MELBOURNE, day( 17 ), day( 26 ) ),
-	                carrierMovement( MELBOURNE, TOKYO, day( 27 ), day( 33 ) )
-	            ) );
+                    carrierMovement( TOKYO, ROTTERDAM, day( 9 ), day( 15 ) ),
+                    carrierMovement( ROTTERDAM, HAMBURG, day( 15 ), day( 16 ) ),
+                    carrierMovement( HAMBURG, MELBOURNE, day( 17 ), day( 26 ) ),
+                    carrierMovement( MELBOURNE, TOKYO, day( 27 ), day( 33 ) )
+                ) );
                 Voyage V500S = voyage( "V500S", schedule(
-	                carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ),
-	                carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) )
-	            ) );
+                    carrierMovement( HAMBURG, STOCKHOLM, day( 17 ), day( 19 ) ),
+                    carrierMovement( STOCKHOLM, HELSINKI, day( 20 ), day( 21 ) )
+                ) );
 
-	            // Cargo and HandlingEvent factories
+                // Cargo and HandlingEvent factories
                 CargosEntity CARGOS = uow.newEntity( CargosEntity.class, CargosEntity.CARGOS_ID );
                 uow.newEntity( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
-	
-	            logger.debug( "BASIC DATA CREATED" );
-	            uow.complete();
+
+                logger.debug( "BASIC DATA CREATED" );
+                uow.complete();
             }
-            catch(Exception e)
+            catch( Exception e )
             {
-            	uow.discard();
-            	logger.error("CANNOT CREATE BASIC DATA");
-            	throw e;
+                uow.discard();
+                logger.error( "CANNOT CREATE BASIC DATA" );
+                throw e;
             }
         }
 
@@ -177,6 +174,5 @@ public interface BaseDataService
             voyage.instance().schedule().set( schedule );
             return voyage.newInstance();
         }
-
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
index c991893..359be79 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/bootstrap/sampledata/SampleDataService.java
@@ -17,13 +17,11 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.bootstrap.sampledata;
 
+import java.time.ZonedDateTime;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.Random;
 import java.util.UUID;
-import org.joda.time.LocalDate;
-import org.joda.time.LocalTime;
 import org.qi4j.api.activation.ActivatorAdapter;
 import org.qi4j.api.activation.Activators;
 import org.qi4j.api.injection.scope.Service;
@@ -55,26 +53,25 @@ import static org.qi4j.sample.dcicargo.sample_a.infrastructure.dci.Context.prepa
 /**
  * Create sample Cargos in different delivery stages
  */
-@Mixins( SampleDataService.Mixin.class )
-@Activators( SampleDataService.Activator.class )
+@Mixins(SampleDataService.Mixin.class)
+@Activators(SampleDataService.Activator.class)
 public interface SampleDataService
     extends ServiceComposite
 {
 
     void insertSampleData()
-            throws Exception;
+        throws Exception;
 
     class Activator
-            extends ActivatorAdapter<ServiceReference<SampleDataService>>
+        extends ActivatorAdapter<ServiceReference<SampleDataService>>
     {
 
         @Override
         public void afterActivation( ServiceReference<SampleDataService> activated )
-                throws Exception
+            throws Exception
         {
             activated.get().insertSampleData();
         }
-
     }
 
     public abstract class Mixin
@@ -87,7 +84,7 @@ public interface SampleDataService
         UnitOfWorkFactory uowf;
 
         @Service // We depend on BaseData to be inserted
-        BaseDataService baseDataService;
+            BaseDataService baseDataService;
 
         private static final Logger logger = LoggerFactory.getLogger( SampleDataService.class );
 
@@ -112,7 +109,7 @@ public interface SampleDataService
                 {
                     String trackingId = cargo.trackingId().get().id().get();
                     ExpectedHandlingEvent nextEvent;
-                    Date time;
+                    ZonedDateTime time;
                     String port;
                     String voyage;
                     HandlingEventType type;
@@ -131,7 +128,7 @@ public interface SampleDataService
                     {
                         nextEvent = cargo.delivery().get().nextExpectedHandlingEvent().get();
                         port = nextEvent.location().get().getCode();
-                        Date mockTime = new Date();
+                        ZonedDateTime mockTime = ZonedDateTime.now();
                         new RegisterHandlingEvent( mockTime, mockTime, trackingId, "RECEIVE", port, null ).register();
                     }
 
@@ -283,7 +280,7 @@ public interface SampleDataService
             Location origin;
             Location destination;
             Random random = new Random();
-            Date deadline;
+            ZonedDateTime deadline;
             String uuid;
             String id;
             try
@@ -299,9 +296,7 @@ public interface SampleDataService
                     }
                     while( destination.equals( origin ) );
 
-                    deadline = new LocalDate().plusDays( 15 + random.nextInt( 10 ) )
-                        .toDateTime( new LocalTime() )
-                        .toDate();
+                    deadline = ZonedDateTime.now().plusDays( 15 + random.nextInt( 10 ) );
 
                     // Build sortable random tracking ids
                     uuid = UUID.randomUUID().toString().toUpperCase();

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java
index b8e3a76..cbf85d2 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/query/dto/HandlingEventDTO.java
@@ -17,7 +17,7 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.communication.query.dto;
 
-import java.util.Date;
+import java.time.ZonedDateTime;
 import org.qi4j.api.common.Optional;
 import org.qi4j.api.property.Property;
 import org.qi4j.library.conversion.values.Unqualified;
@@ -36,7 +36,7 @@ import org.qi4j.sample.dcicargo.sample_a.infrastructure.conversion.DTO;
 @Unqualified
 public interface HandlingEventDTO extends DTO
 {
-    Property<Date> completionTime();
+    Property<ZonedDateTime> completionTime();
 
     Property<TrackingId> trackingId();
 

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java
index ccb6946..6a0df02 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/BookNewCargoPage.java
@@ -17,6 +17,9 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.communication.web.booking;
 
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
 import java.util.Date;
 import java.util.List;
 import org.apache.wicket.Session;
@@ -27,7 +30,6 @@ import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.joda.time.LocalDate;
 import org.qi4j.sample.dcicargo.sample_a.communication.query.CommonQueries;
 import org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo;
 import org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId;
@@ -58,7 +60,7 @@ public class BookNewCargoPage extends BookingBasePage
     {
         // Set by Wicket property resolvers:
         private String origin, destination;
-        private Date deadline;
+        private Date wicketSetDeadline;
 
         public BookNewCargoForm()
         {
@@ -108,7 +110,7 @@ public class BookNewCargoPage extends BookingBasePage
 
             // Deadline
             final DateTextFieldWithPicker deadlineField = new DateTextFieldWithPicker( "deadline", "Arrival deadline", this );
-            deadlineField.earliestDate( new LocalDate().plusDays( 1 ) );
+            deadlineField.earliestDate( ZonedDateTime.now().plusDays( 1 ) );
 
             final ComponentFeedbackPanel deadlineFeedback = new ComponentFeedbackPanel(
                 "deadlineFeedback", deadlineField );
@@ -124,6 +126,8 @@ public class BookNewCargoPage extends BookingBasePage
                     try
                     {
                         // Perform use case
+                        Instant instant = Instant.ofEpochMilli( wicketSetDeadline.getTime() );
+                        ZonedDateTime deadline = ZonedDateTime.ofInstant( instant, ZoneId.systemDefault() );
                         TrackingId trackingId = new BookNewCargo( origin, destination, deadline ).book();
 
                         // Add new tracking id to list in session

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b71c878d/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
----------------------------------------------------------------------
diff --git a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
index 2b44087..dee31f1 100644
--- a/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
+++ b/samples/dci-cargo/dcisample_a/src/main/java/org/qi4j/sample/dcicargo/sample_a/communication/web/booking/CargoDetailsPage.java
@@ -17,6 +17,7 @@
  */
 package org.qi4j.sample.dcicargo.sample_a.communication.web.booking;
 
+import java.time.LocalTime;
 import java.util.Date;
 import java.util.List;
 import org.apache.wicket.AttributeModifier;
@@ -140,14 +141,14 @@ public class CargoDetailsPage extends BookingBasePage
                     Leg leg = item.getModelObject();
 
                     item.add( new Label( "loadLocation", leg.loadLocation().get().getCode() ) );
-                    item.add( new Label( "loadTime", new Model<Date>( leg.loadTime().get() ) ) );
+                    item.add( new Label( "loadTime", new Model<Date>( new Date( leg.loadTime().get().toInstant().toEpochMilli() )) ) );
                     item.add( new Label( "voyage", leg.voyage().get().voyageNumber().get().number().get() ) );
 
                     Boolean isMisrouted = routingStatus == RoutingStatus.MISROUTED && item.getIndex() == ( getList().size() - 1 );
                     item.add( new Label( "unloadLocation", leg.unloadLocation().get().getCode() )
                                   .add( new ErrorColor( isMisrouted ) ) );
 
-                    item.add( new Label( "unloadTime", new Model<Date>( leg.unloadTime().get() ) ) );
+                    item.add( new Label( "unloadTime", new Model<Date>( new Date( leg.unloadTime().get().toInstant().toEpochMilli() ) ) ) );
                 }
             } );
         }


Mime
View raw message