← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17111: Replace Cal class with Joda time in test classes.

 

------------------------------------------------------------
revno: 17111
committer: Tran Chau<tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-14 20:30:08 +0700
message:
  Replace Cal class with Joda time in test classes.
modified:
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialAprilPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialJulyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialOctoberPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/MonthlyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/QuarterlyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java
  dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/YearlyPeriodTypeTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/BiMonthlyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,6 +32,7 @@
 
 import java.util.List;
 
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,121 +41,116 @@
  */
 public class BiMonthlyPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private BiMonthlyPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
         periodType = new BiMonthlyPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 8, 15 );
-        
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2009, 8, 31 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 3, 15 );
-        
-        startCal.set( 2009, 3, 1 );
-        endCal.set( 2009, 4, 30 );
-
-        period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        startDate = new DateTime( 2009, 7, 1, 0, 0 );
+        endDate = new DateTime(2009, 8, 31, 0, 0 );
+        testDate = new DateTime(2009, 8, 15, 0, 0 );
+        
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        startDate = new DateTime( 2009, 3, 1, 0, 0 );
+        endDate = new DateTime( 2009, 4, 30, 0, 0 );
+        testDate = new DateTime( 2009, 3, 15, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
-    {
-        testCal.set( 2009, 8, 15 );
-
-        Period period = periodType.createPeriod( testCal.time() );
+    { 
+        testDate = new DateTime(2009, 8, 15, 0, 0 );
+      
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
-
-        startCal.set( 2009, 9, 1 );
-        endCal.set( 2009, 10, 31 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+       
+        startDate = new DateTime( 2009, 9, 1, 0, 0 );
+        endDate = new DateTime( 2009, 10, 31, 0, 0 );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime( 2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2009, 5, 1 );
-        endCal.set( 2009, 6, 30 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        startDate = new DateTime( 2009, 5, 1, 0, 0 );
+        endDate = new DateTime( 2009, 6, 30, 0, 0 );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime( 2009, 8, 15, 0, 0 );
         
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
         
         assertEquals( 6, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 3, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 5, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 9, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 11, 1 ).time() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 3, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 5, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 7, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 9, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 11, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
     }
 
     @Test
     public void testGenerateRollingPeriods()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime( 2009, 8, 15, 0, 0 );
         
-        List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
+        List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
         
         assertEquals( 6, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 9, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 11, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 3, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 5, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2008, 9, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2008, 11, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 1, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 3, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 5, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 7, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
     }
     
     @Test
     public void testGenerateLast5Years()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime( 2009, 8, 15, 0, 0 );
         
-        List<Period> periods = periodType.generateLast5Years( testCal.time() );
+        List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
         
         assertEquals( 30, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 3, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 5, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 7, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 9, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 11, 1 ).time() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 3, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 5, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 7, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 9, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 11, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialAprilPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialAprilPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialAprilPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,7 +32,7 @@
 
 import java.util.List;
 
-import org.hisp.dhis.period.Cal;
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -41,101 +41,98 @@
  */
 public class FinancialAprilPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private CalendarPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
         periodType = new FinancialAprilPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 2, 15 );
-
-        startCal.set( 2008, 4, 1 );
-        endCal.set( 2009, 3, 31 );
-        
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 9, 12 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2010, 3, 31 );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime( 2009, 2, 15, 0, 0 );
+
+        startDate = new DateTime( 2008, 4, 1, 0, 0 );
+        endDate = new DateTime( 2009, 3, 31, 0, 0 );
+        
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        testDate = new DateTime( 2009, 9, 12, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        startDate = new DateTime( 2009, 4, 1, 0, 0 );
+        endDate = new DateTime( 2010, 3, 31, 0, 0 );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime( 2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2010, 3, 31 );
+        startDate = new DateTime( 2009, 4, 1, 0, 0 );
+        endDate = new DateTime( 2010, 3, 31, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime( 2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2007, 4, 1 );
-        endCal.set( 2008, 3, 31 );
+        startDate = new DateTime( 2007, 4, 1, 0, 0 );
+        endDate = new DateTime( 2008, 3, 31, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 2, 15 );
-        
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2003, 4, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 4, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 4, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2006, 4, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2007, 4, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 4, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 4, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2011, 4, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2012, 4, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2013, 4, 1 ).time() ), periods.get( 10 ) );
-        
-        testCal.set( 2009, 9, 12 );
-        
-        periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 4, 1 ).time() ), periods.get( 0 ) );
+        testDate = new DateTime( 2009, 2, 15, 0, 0 );
+        
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime( 2003, 4, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2004, 4, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2005, 4, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2006, 4, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2007, 4, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2008, 4, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2009, 4, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2010, 4, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2011, 4, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2012, 4, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime( 2013, 4, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        
+        testDate = new DateTime( 2009, 9, 12, 0, 0 );
+        
+        periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime( 2004, 4, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialJulyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialJulyPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialJulyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,6 +32,7 @@
 
 import java.util.List;
 
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,101 +41,98 @@
  */
 public class FinancialJulyPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private CalendarPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
-        periodType = new FinancialJulyPeriodType();
+         periodType = new FinancialJulyPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 2, 15 );
-
-        startCal.set( 2008, 7, 1 );
-        endCal.set( 2009, 6, 30 );
-        
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 9, 12 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2010, 6, 30 );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
+
+        startDate = new DateTime(  2008, 7, 1, 0, 0 );
+        endDate = new DateTime(  2009, 6, 30, 0, 0 );
+        
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        testDate = new DateTime(  2009, 9, 12, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        startDate = new DateTime(  2009, 7, 1, 0, 0 );
+        endDate = new DateTime(  2010, 6, 30, 0, 0 );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2010, 6, 30 );
+        startDate = new DateTime(  2009, 7, 1, 0, 0 );
+        endDate = new DateTime(  2010, 6, 30, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2007, 7, 1 );
-        endCal.set( 2008, 6, 30 );
+        startDate = new DateTime(  2007, 7, 1, 0, 0 );
+        endDate = new DateTime(  2008, 6, 30, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 2, 15 );
-        
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2003, 7, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 7, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 7, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2006, 7, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2007, 7, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 7, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 7, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2011, 7, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2012, 7, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2013, 7, 1 ).time() ), periods.get( 10 ) );
-        
-        testCal.set( 2009, 9, 12 );
-        
-        periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 7, 1 ).time() ), periods.get( 0 ) );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
+        
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2003, 7, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2004, 7, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 7, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2006, 7, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2007, 7, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 7, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 7, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2011, 7, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2012, 7, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2013, 7, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        
+        testDate = new DateTime( 2009, 9, 12, 0, 0 );
+        
+        periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2004, 7, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialOctoberPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialOctoberPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/FinancialOctoberPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,7 +32,7 @@
 
 import java.util.List;
 
-import org.hisp.dhis.period.Cal;
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -41,101 +41,98 @@
  */
 public class FinancialOctoberPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private CalendarPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
         periodType = new FinancialOctoberPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 2, 15 );
-
-        startCal.set( 2008, 10, 1 );
-        endCal.set( 2009, 9, 30 );
-        
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 11, 12 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        startCal.set( 2009, 10, 1 );
-        endCal.set( 2010, 9, 30 );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
+
+        startDate = new DateTime(  2008, 10, 1, 0, 0 );
+        endDate = new DateTime(  2009, 9, 30, 0, 0 );
+        
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        testDate = new DateTime(  2009, 11, 12, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        startDate = new DateTime(  2009, 10, 1, 0, 0 );
+        endDate = new DateTime(  2010, 9, 30, 0, 0 );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2009, 10, 1 );
-        endCal.set( 2010, 9, 30 );
+        startDate = new DateTime(  2009, 10, 1, 0, 0 );
+        endDate = new DateTime(  2010, 9, 30, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 2, 15 );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2007, 10, 1 );
-        endCal.set( 2008, 9, 30 );
+        startDate = new DateTime(  2007, 10, 1, 0, 0 );
+        endDate = new DateTime(  2008, 9, 30, 0, 0 );
         
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 2, 15 );
-        
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2003, 10, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 10, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 10, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2006, 10, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2007, 10, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 10, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 10, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2011, 10, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2012, 10, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2013, 10, 1 ).time() ), periods.get( 10 ) );
-        
-        testCal.set( 2009, 11, 12 );
-        
-        periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 10, 1 ).time() ), periods.get( 0 ) );
+        testDate = new DateTime(  2009, 2, 15, 0, 0 );
+        
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2003, 10, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2004, 10, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 10, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2006, 10, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2007, 10, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 10, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 10, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2011, 10, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2012, 10, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2013, 10, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        
+        testDate = new DateTime(  2009, 11, 12, 0, 0 );
+        
+        periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 11, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2004, 10, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/MonthlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/MonthlyPeriodTypeTest.java	2014-10-08 11:27:45 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/MonthlyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -139,18 +139,18 @@
         List<Period> periods = periodType.generatePeriods( testDate.toDate() );
         
         assertEquals( 12, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 2, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 3, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 5, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 6, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 8, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 9, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 11, 1 ).time() ), periods.get( 10 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 12, 1 ).time() ), periods.get( 11 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 2, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 3, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 5, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 6, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 8, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 9, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 11, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 12, 1, 0, 0 ).toDate() ), periods.get( 11 ) );
     }
 
     @Test
@@ -161,18 +161,18 @@
         List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
         
         assertEquals( 12, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 9, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 10, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 11, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 12, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 2, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 3, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 5, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 6, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 10 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 8, 1 ).time() ), periods.get( 11 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 9, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 10, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 11, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 12, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 2, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 3, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 5, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 6, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 8, 1, 0, 0 ).toDate() ), periods.get( 11 ) );
     }
     
     @Test
@@ -183,18 +183,18 @@
         List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
         
         assertEquals( 60, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 2, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 3, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 4, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 5, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 6, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 7, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 8, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 9, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 10, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 11, 1 ).time() ), periods.get( 10 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 12, 1 ).time() ), periods.get( 11 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 2, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 3, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 4, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 5, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 6, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 7, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 8, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 9, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 10, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 11, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 12, 1, 0, 0 ).toDate() ), periods.get( 11 ) );
     }
     
     @Test
@@ -206,13 +206,13 @@
         List<Period> periods = periodType.generatePeriods( startDate.toDate(), endDate.toDate() );
 
         assertEquals( 7, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 8, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 9, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 11, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 12, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 1, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 2, 1 ).time() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 8, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 9, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 11, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 12, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 1, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 2, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
     }
     
     @Test

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/QuarterlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/QuarterlyPeriodTypeTest.java	2014-05-21 14:06:05 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/QuarterlyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,52 +41,49 @@
  */
 public class QuarterlyPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private QuarterlyPeriodType periodType;
 
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
-        periodType = new QuarterlyPeriodType();
+       periodType = new QuarterlyPeriodType();
     }
 
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 8, 15 );
-
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2009, 9, 30 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 4, 15 );
-
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2009, 6, 30 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2014, 11, 20 );
-
-        startCal.set( 2014, 10, 1 );
-        endCal.set( 2014, 12, 31 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
+
+        startDate = new DateTime(  2009, 7, 1, 0, 0 );
+        endDate = new DateTime(  2009, 9, 30, 0, 0 );
+
+        Period period = periodType.createPeriod( testDate.toDate() );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+
+        startDate = new DateTime(  2009, 4, 1, 0, 0 );
+        endDate = new DateTime(  2009, 6, 30, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2014, 11, 20, 0, 0 );
+
+        startDate = new DateTime(  2014, 10, 1, 0, 0 );
+        endDate = new DateTime(  2014, 12, 31, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
@@ -97,89 +95,89 @@
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
 
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2009, 10, 1 );
-        endCal.set( 2009, 12, 31 );
+        startDate = new DateTime(  2009, 10, 1, 0, 0 );
+        endDate = new DateTime(  2009, 12, 31, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
 
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2009, 6, 30 );
+        startDate = new DateTime(  2009, 4, 1, 0, 0 );
+        endDate = new DateTime(  2009, 6, 30, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
 
         assertEquals( 4, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
     }
 
     @Test
     public void testGenerateRollingPeriods()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
+        List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
 
         assertEquals( 4, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 10, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 10, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
     }
 
     @Test
     public void testGenerateLast5Years()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        List<Period> periods = periodType.generateLast5Years( testCal.time() );
+        List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
 
         assertEquals( 20, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 4, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 7, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 10, 1 ).time() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 4, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 7, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 10, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
     }
 
     @Test
     public void testGeneratePeriodsBetweenDates()
     {
-        startCal.set( 2009, 8, 15 );
-        endCal.set( 2010, 2, 20 );
+        startDate = new DateTime(  2009, 8, 15, 0, 0 );
+        endDate = new DateTime(  2010, 2, 20, 0, 0 );
 
-        List<Period> periods = periodType.generatePeriods( startCal.time(), endCal.time() );
+        List<Period> periods = periodType.generatePeriods( startDate.toDate(), endDate.toDate() );
 
         assertEquals( 3, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 1, 1 ).time() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 1, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
     }
 
     @Test

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyAprilPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,6 +32,7 @@
 
 import java.util.List;
 
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,149 +41,146 @@
  */
 public class SixMonthlyAprilPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private SixMonthlyAprilPeriodType periodType;
 
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
         periodType = new SixMonthlyAprilPeriodType();
     }
 
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 8, 15 );
-
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2009, 9, 30 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 12, 15 );
-
-        startCal.set( 2009, 10, 1 );
-        endCal.set( 2010, 3, 31 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
+
+        startDate = new DateTime(  2009, 4, 1, 0 ,0 );
+        endDate = new DateTime(  2009, 9, 30, 0 ,0 );
+
+        Period period = periodType.createPeriod( testDate.toDate() );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 12, 15, 0 ,0 );
+
+        startDate = new DateTime(  2009, 10, 1, 0 ,0 );
+        endDate = new DateTime(  2010, 3, 31, 0 ,0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 8, 15 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-
-        period = periodType.getNextPeriod( period );
-
-        startCal.set( 2009, 10, 1 );
-        endCal.set( 2010, 3, 31 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 12, 15 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        period = periodType.getNextPeriod( period );
-
-        startCal.set( 2010, 4, 1 );
-        endCal.set( 2010, 9, 30 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
+
+        Period period = periodType.createPeriod( testDate.toDate() );
+
+        period = periodType.getNextPeriod( period );
+
+        startDate = new DateTime(  2009, 10, 1, 0 ,0 );
+        endDate = new DateTime(  2010, 3, 31, 0 ,0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 12, 15, 0 ,0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        period = periodType.getNextPeriod( period );
+
+        startDate = new DateTime(  2010, 4, 1, 0 ,0 );
+        endDate = new DateTime(  2010, 9, 30, 0 ,0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 8, 15 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-
-        period = periodType.getPreviousPeriod( period );
-
-        startCal.set( 2008, 10, 1 );
-        endCal.set( 2009, 3, 31 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 12, 15 );
-
-        period = periodType.createPeriod( testCal.time() );
-
-        period = periodType.getPreviousPeriod( period );
-
-        startCal.set( 2009, 4, 1 );
-        endCal.set( 2009, 9, 30 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
+
+        Period period = periodType.createPeriod( testDate.toDate() );
+
+        period = periodType.getPreviousPeriod( period );
+
+        startDate = new DateTime(  2008, 10, 1, 0 ,0 );
+        endDate = new DateTime(  2009, 3, 31, 0 ,0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 12, 15, 0 ,0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+
+        period = periodType.getPreviousPeriod( period );
+
+        startDate = new DateTime(  2009, 4, 1, 0 ,0 );
+        endDate = new DateTime(  2009, 9, 30, 0 ,0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 8, 15 );
-
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
-
-        testCal.set( 2009, 12, 15 );
-
-        periods = periodType.generatePeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
+
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+
+        testDate = new DateTime(  2009, 12, 15, 0 ,0 );
+
+        periods = periodType.generatePeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
     }
 
     @Test
     public void testGenerateRollingPeriods()
     {
-        testCal.set( 2009, 8, 15 );
-
-        List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 10, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 1 ) );
-
-        testCal.set( 2009, 12, 15 );
-
-        periods = periodType.generateRollingPeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 4, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 10, 1 ).time() ), periods.get( 1 ) );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
+
+        List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 10, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
+
+        testDate = new DateTime(  2009, 12, 15, 0 ,0 );
+
+        periods = periodType.generateRollingPeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
     }
 
     @Test
     public void testGenerateLast5Years()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0 ,0 );
 
-        List<Period> periods = periodType.generateLast5Years( testCal.time() );
+        List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
 
         assertEquals( 10, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 4, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 10, 1 ).time() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 4, 1, 0 ,0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 10, 1, 0 ,0 ).toDate() ), periods.get( 1 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/SixMonthlyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,6 +32,7 @@
 
 import java.util.List;
 
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -40,149 +41,146 @@
  */
 public class SixMonthlyPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private SixMonthlyPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
-        periodType = new SixMonthlyPeriodType();
+       periodType = new SixMonthlyPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 8, 15 );
-        
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2009, 12, 31 );
-
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 4, 15 );
-        
-        startCal.set( 2009, 1, 1 );
-        endCal.set( 2009, 6, 30 );
-
-        period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
+        
+        startDate = new DateTime( 2009, 7, 1, 0, 0 );
+        endDate = new DateTime( 2009, 12, 31, 0, 0 );
+
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+        
+        startDate = new DateTime(  2009, 1, 1, 0, 0 );
+        endDate = new DateTime(  2009, 6, 30, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2010, 1, 1 );
-        endCal.set( 2010, 6, 30 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 4, 15 );
-
-        period = periodType.createPeriod( testCal.time() );
+        startDate = new DateTime(  2010, 1, 1, 0, 0 );
+        endDate = new DateTime(  2010, 6, 30, 0, 0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
 
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2009, 7, 1 );
-        endCal.set( 2009, 12, 31 );
+        startDate = new DateTime(  2009, 7, 1, 0, 0 );
+        endDate = new DateTime(  2009, 12, 31, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2009, 1, 1 );
-        endCal.set( 2009, 6, 30 );
-
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-
-        testCal.set( 2009, 4, 15 );
-
-        period = periodType.createPeriod( testCal.time() );
+        startDate = new DateTime(  2009, 1, 1, 0, 0 );
+        endDate = new DateTime(  2009, 6, 30, 0, 0 );
+
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+
+        period = periodType.createPeriod( testDate.toDate() );
 
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2008, 7, 1 );
-        endCal.set( 2008, 12, 31 );
+        startDate = new DateTime(  2008, 7, 1, 0, 0 );
+        endDate = new DateTime(  2008, 12, 31, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 8, 15 );
-        
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
-        
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
-
-        testCal.set( 2009, 4, 15 );
-
-        periods = periodType.generatePeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
+        
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
+        
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+
+        periods = periodType.generatePeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
     }
 
     @Test
     public void testGenerateRollingPeriods()
     {
-        testCal.set( 2009, 8, 15 );
-        
-        List<Period> periods = periodType.generateRollingPeriods( testCal.time() );
-        
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 7, 1 ).time() ), periods.get( 1 ) );
-
-        testCal.set( 2009, 4, 15 );
-
-        periods = periodType.generateRollingPeriods( testCal.time() );
-
-        assertEquals( 2, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 7, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 1 ) );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
+        
+        List<Period> periods = periodType.generateRollingPeriods( testDate.toDate() );
+        
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 7, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+
+        periods = periodType.generateRollingPeriods( testDate.toDate() );
+
+        assertEquals( 2, periods.size() );
+        assertEquals( periodType.createPeriod(new DateTime(  2008, 7, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
     }
     
     @Test
     public void testGenerateLast5Years()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
         
-        List<Period> periods = periodType.generateLast5Years( testCal.time() );
+        List<Period> periods = periodType.generateLast5Years( testDate.toDate() );
         
         assertEquals( 10, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 7, 1 ).time() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2005, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod(new DateTime(  2005, 7, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
     }
 }

=== modified file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/YearlyPeriodTypeTest.java'
--- dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/YearlyPeriodTypeTest.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/period/YearlyPeriodTypeTest.java	2014-10-14 13:30:08 +0000
@@ -32,7 +32,7 @@
 
 import java.util.List;
 
-import org.hisp.dhis.period.Cal;
+import org.joda.time.DateTime;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -41,106 +41,103 @@
  */
 public class YearlyPeriodTypeTest
 {
-    private Cal startCal;
-    private Cal endCal;
-    private Cal testCal;
+    private DateTime startDate;
+    private DateTime endDate;
+    private DateTime testDate;
     private CalendarPeriodType periodType;
     
     @Before
     public void before()
     {
-        startCal = new Cal();
-        endCal = new Cal();
-        testCal = new Cal();
         periodType = new YearlyPeriodType();
     }
     
     @Test
     public void testCreatePeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
         
-        startCal.set( 2009, 1, 1 );
-        endCal.set( 2009, 12, 31 );
+        startDate = new DateTime(  2009, 1, 1, 0, 0 );
+        endDate = new DateTime(  2009, 12, 31, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
-        
-        testCal.set( 2009, 4, 15 );
-        
-        period = periodType.createPeriod( testCal.time() );
-        
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        Period period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
+        
+        testDate = new DateTime(  2009, 4, 15, 0, 0 );
+        
+        period = periodType.createPeriod( testDate.toDate() );
+        
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
 
     @Test
     public void testGetNextPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getNextPeriod( period );
 
-        startCal.set( 2010, 1, 1 );
-        endCal.set( 2010, 12, 31 );
+        startDate = new DateTime(  2010, 1, 1, 0, 0 );
+        endDate = new DateTime(  2010, 12, 31, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGetPreviousPeriod()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
 
-        Period period = periodType.createPeriod( testCal.time() );
+        Period period = periodType.createPeriod( testDate.toDate() );
         
         period = periodType.getPreviousPeriod( period );
 
-        startCal.set( 2008, 1, 1 );
-        endCal.set( 2008, 12, 31 );
+        startDate = new DateTime(  2008, 1, 1, 0, 0 );
+        endDate = new DateTime(  2008, 12, 31, 0, 0 );
 
-        assertEquals( startCal.time(), period.getStartDate() );
-        assertEquals( endCal.time(), period.getEndDate() );
+        assertEquals( startDate.toDate(), period.getStartDate() );
+        assertEquals( endDate.toDate(), period.getEndDate() );
     }
     
     @Test
     public void testGeneratePeriods()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
         
-        List<Period> periods = periodType.generatePeriods( testCal.time() );
+        List<Period> periods = periodType.generatePeriods( testDate.toDate() );
         
         assertEquals( 11, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2004, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2006, 1, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2007, 1, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 1, 1 ).time() ), periods.get( 4 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 5 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2010, 1, 1 ).time() ), periods.get( 6 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2011, 1, 1 ).time() ), periods.get( 7 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2012, 1, 1 ).time() ), periods.get( 8 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2013, 1, 1 ).time() ), periods.get( 9 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2014, 1, 1 ).time() ), periods.get( 10 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2004, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 1, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2006, 1, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2007, 1, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 1, 1, 0, 0 ).toDate() ), periods.get( 4 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 5 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2010, 1, 1, 0, 0 ).toDate() ), periods.get( 6 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2011, 1, 1, 0, 0 ).toDate() ), periods.get( 7 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2012, 1, 1, 0, 0 ).toDate() ), periods.get( 8 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2013, 1, 1, 0, 0 ).toDate() ), periods.get( 9 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2014, 1, 1, 0, 0 ).toDate() ), periods.get( 10 ) );
     }
     
     @Test
     public void testGenerateLast5Years()
     {
-        testCal.set( 2009, 8, 15 );
+        testDate = new DateTime(  2009, 8, 15, 0, 0 );
         
-        List<Period> periods = new YearlyPeriodType().generateLast5Years( testCal.time() );
+        List<Period> periods = new YearlyPeriodType().generateLast5Years( testDate.toDate() );
 
         assertEquals( 5, periods.size() );
-        assertEquals( periodType.createPeriod( new Cal( 2005, 1, 1 ).time() ), periods.get( 0 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2006, 1, 1 ).time() ), periods.get( 1 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2007, 1, 1 ).time() ), periods.get( 2 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2008, 1, 1 ).time() ), periods.get( 3 ) );
-        assertEquals( periodType.createPeriod( new Cal( 2009, 1, 1 ).time() ), periods.get( 4 ) );        
+        assertEquals( periodType.createPeriod( new DateTime(  2005, 1, 1, 0, 0 ).toDate() ), periods.get( 0 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2006, 1, 1, 0, 0 ).toDate() ), periods.get( 1 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2007, 1, 1, 0, 0 ).toDate() ), periods.get( 2 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2008, 1, 1, 0, 0 ).toDate() ), periods.get( 3 ) );
+        assertEquals( periodType.createPeriod( new DateTime(  2009, 1, 1, 0, 0 ).toDate() ), periods.get( 4 ) );        
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java	2014-03-24 22:19:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventQueryPlannerTest.java	2014-10-14 13:30:08 +0000
@@ -39,8 +39,8 @@
 import org.hisp.dhis.analytics.event.EventQueryPlanner;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.program.Program;
+import org.joda.time.DateTime;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 
@@ -81,8 +81,8 @@
     {        
         EventQueryParams params = new EventQueryParams();
         params.setProgram( prA );
-        params.setStartDate( new Cal( 2010, 6, 1 ).time() );
-        params.setEndDate( new Cal( 2012, 3, 20 ).time() );
+        params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
+        params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
         params.setOrganisationUnits( Arrays.asList( ouA ) );
         
         List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -91,8 +91,8 @@
         
         EventQueryParams query = queries.get( 0 );
         
-        assertEquals( new Cal( 2010, 6, 1 ).time(), query.getStartDate() );
-        assertEquals( new Cal( 2012, 3, 20 ).time(), query.getEndDate() );
+        assertEquals( new DateTime( 2010, 6, 1, 0, 0 ).toDate(), query.getStartDate() );
+        assertEquals( new DateTime( 2012, 3, 20, 0, 0 ).toDate(), query.getEndDate() );
         
         Partitions partitions = query.getPartitions();
         
@@ -107,8 +107,8 @@
     {        
         EventQueryParams params = new EventQueryParams();
         params.setProgram( prA );
-        params.setStartDate( new Cal( 2010, 3, 1 ).time() );
-        params.setEndDate( new Cal( 2010, 9, 20 ).time() );
+        params.setStartDate( new DateTime( 2010, 3, 1, 0, 0 ).toDate() );
+        params.setEndDate( new DateTime( 2010, 9, 20, 0, 0 ).toDate() );
         params.setOrganisationUnits( Arrays.asList( ouA ) );
         
         List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -117,8 +117,8 @@
 
         EventQueryParams query = queries.get( 0 );
         
-        assertEquals( new Cal( 2010, 3, 1 ).time(), query.getStartDate() );
-        assertEquals( new Cal( 2010, 9, 20 ).time(), query.getEndDate() );
+        assertEquals( new DateTime( 2010, 3, 1, 0, 0 ).toDate(), query.getStartDate() );
+        assertEquals( new DateTime( 2010, 9, 20, 0, 0 ).toDate(), query.getEndDate() );
 
         Partitions partitions = query.getPartitions();
 
@@ -131,8 +131,8 @@
     {        
         EventQueryParams params = new EventQueryParams();
         params.setProgram( prA );
-        params.setStartDate( new Cal( 2010, 6, 1 ).time() );
-        params.setEndDate( new Cal( 2012, 3, 20 ).time() );
+        params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
+        params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
         params.setOrganisationUnits( Arrays.asList( ouA, ouB ) );
         
         List<EventQueryParams> queries = queryPlanner.planAggregateQuery( params );
@@ -147,14 +147,14 @@
     {        
         EventQueryParams params = new EventQueryParams();
         params.setProgram( prA );
-        params.setStartDate( new Cal( 2010, 6, 1 ).time() );
-        params.setEndDate( new Cal( 2012, 3, 20 ).time() );
+        params.setStartDate( new DateTime( 2010, 6, 1, 0, 0 ).toDate() );
+        params.setEndDate( new DateTime( 2012, 3, 20, 0, 0 ).toDate() );
         params.setOrganisationUnits( Arrays.asList( ouA ) );
         
         params = queryPlanner.planEventQuery( params );
         
-        assertEquals( new Cal( 2010, 6, 1 ).time(), params.getStartDate() );
-        assertEquals( new Cal( 2012, 3, 20 ).time(), params.getEndDate() );
+        assertEquals( new DateTime( 2010, 6, 1, 0, 0 ).toDate(), params.getStartDate() );
+        assertEquals( new DateTime( 2012, 3, 20, 0, 0 ).toDate(), params.getEndDate() );
         
         Partitions partitions = params.getPartitions();
         
@@ -169,14 +169,14 @@
     {        
         EventQueryParams params = new EventQueryParams();
         params.setProgram( prA );
-        params.setStartDate( new Cal( 2010, 3, 1 ).time() );
-        params.setEndDate( new Cal( 2010, 9, 20 ).time() );
+        params.setStartDate( new DateTime( 2010, 3, 1, 0, 0 ).toDate() );
+        params.setEndDate( new DateTime( 2010, 9, 20, 0, 0 ).toDate() );
         params.setOrganisationUnits( Arrays.asList( ouA ) );
         
         params = queryPlanner.planEventQuery( params );
 
-        assertEquals( new Cal( 2010, 3, 1 ).time(), params.getStartDate() );
-        assertEquals( new Cal( 2010, 9, 20 ).time(), params.getEndDate() );
+        assertEquals( new DateTime( 2010, 3, 1, 0, 0 ).toDate(), params.getStartDate() );
+        assertEquals( new DateTime( 2010, 9, 20, 0, 0 ).toDate(), params.getEndDate() );
 
         Partitions partitions = params.getPartitions();
 

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/table/PartitionUtilsTest.java	2014-10-14 13:30:08 +0000
@@ -42,8 +42,8 @@
 import org.hisp.dhis.analytics.Partitions;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.NameableObject;
-import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.period.Period;
+import org.joda.time.DateTime;
 import org.junit.Test;
 
 /**
@@ -94,16 +94,16 @@
     public void getGetPartitionsLongPeriods()
     {
         Period period = new Period();
-        period.setStartDate( new Cal( 2008, 3, 1 ).time() );
-        period.setEndDate( new Cal( 2011, 7, 1 ).time() );
+        period.setStartDate( new DateTime( 2008, 3, 1, 0, 0 ).toDate() );
+        period.setEndDate( new DateTime( 2011, 7, 1, 0, 0 ).toDate() );
         
         Partitions expected = new Partitions().add( TBL + "_2008" ).add( TBL + "_2009" ).add( TBL + "_2010" ).add( TBL + "_2011" );
         
         assertEquals( expected, PartitionUtils.getPartitions( period, TBL, null, null ) );
         
         period = new Period();
-        period.setStartDate( new Cal( 2009, 8, 1 ).time() );
-        period.setEndDate( new Cal( 2010, 2, 1 ).time() );
+        period.setStartDate( new DateTime( 2009, 8, 1, 0, 0 ).toDate() );
+        period.setEndDate( new DateTime( 2010, 2, 1, 0, 0 ).toDate() );
         
         expected = new Partitions().add( TBL + "_2009" ).add( TBL + "_2010" );
         
@@ -114,8 +114,8 @@
     public void getGetPartitionsLongPeriodsPrune()
     {
         Period period = new Period();
-        period.setStartDate( new Cal( 2008, 3, 1 ).time() );
-        period.setEndDate( new Cal( 2011, 7, 1 ).time() );
+        period.setStartDate( new DateTime( 2008, 3, 1, 0, 0 ).toDate() );
+        period.setEndDate( new DateTime( 2011, 7, 1, 0, 0 ).toDate() );
         
         Partitions expected = new Partitions().add( TBL + "_2008" ).add( TBL + "_2009" ).add( TBL + "_2010" ).add( TBL + "_2011" );
         

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java	2014-10-13 12:28:52 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java	2014-10-14 13:30:08 +0000
@@ -46,13 +46,13 @@
 import org.hisp.dhis.dxf2.importsummary.ImportStatus;
 import org.hisp.dhis.dxf2.importsummary.ImportSummary;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.period.Cal;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.trackedentity.TrackedEntity;
 import org.hisp.dhis.trackedentity.TrackedEntityService;
+import org.joda.time.DateTime;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -227,7 +227,7 @@
         assertEquals( maleA.getUid(), enrollment.getTrackedEntityInstance() );
         assertEquals( programA.getUid(), enrollment.getProgram() );
 
-        Date MARCH_20_81 = new Cal( 81, 2, 20 ).time();
+        Date MARCH_20_81 = new DateTime( 81, 2, 20, 0, 0 ).toDate();
 
         enrollment.setDateOfEnrollment( MARCH_20_81 );
         enrollmentService.updateEnrollment( enrollment );

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java	2014-09-14 19:39:53 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/DateUtilsTest.java	2014-10-14 13:30:08 +0000
@@ -29,11 +29,11 @@
  */
 
 import static org.hisp.dhis.system.util.DateUtils.dateIsValid;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
 
-import org.hisp.dhis.period.Cal;
+import org.joda.time.DateTime;
 import org.junit.Test;
 
 /**
@@ -55,6 +55,6 @@
     @Test
     public void testDaysBetween()
     {
-        assertEquals( 6, DateUtils.daysBetween( new Cal( 2014, 3, 1 ).time(), new Cal( 2014, 3, 7 ).time() ) );
+        assertEquals( 6, DateUtils.daysBetween( new DateTime( 2014, 3, 1, 0, 0 ).toDate(), new DateTime( 2014, 3, 7, 0, 0 ).toDate() ) );
     }
 }