← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19826: allow to pass in calendar in CalendarPeriodType.generatePeriods, makes it easier to test

 

------------------------------------------------------------
revno: 19826
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-24 11:40:28 +0700
message:
  allow to pass in calendar in CalendarPeriodType.generatePeriods, makes it easier to test
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.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/main/java/org/hisp/dhis/period/CalendarPeriodType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java	2015-04-08 22:57:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/CalendarPeriodType.java	2015-08-24 04:40:28 +0000
@@ -139,7 +139,7 @@
     public List<Period> generateRollingPeriods( Date date )
     {
         DateTimeUnit dateTime = createLocalDateUnitInstance( date );
-        
+
         return generateRollingPeriods( dateTime );
     }
 
@@ -170,6 +170,11 @@
         return periods;
     }
 
+    public List<Period> generatePeriods( Date startDate, Date endDate )
+    {
+        return generatePeriods( getCalendar(), startDate, endDate );
+    }
+
     /**
      * Generates a list of all Periods between the given start and end date. The
      * first period will span the start date. The last period will span the end
@@ -179,14 +184,12 @@
      * @param endDate   the end date.
      * @return a list of Periods for the defined time span.
      */
-    public List<Period> generatePeriods( Date startDate, Date endDate )
+    public List<Period> generatePeriods( Calendar calendar, Date startDate, Date endDate )
     {
         List<Period> periods = new ArrayList<>();
 
         Period period = createPeriod( startDate );
 
-        Calendar calendar = getCalendar();
-
         while ( period.getStartDate().before( endDate ) )
         {
             periods.add( period );