=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2011-02-24 21:01:47 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/period/Cal.java 2011-10-23 13:02:22 +0000 @@ -25,6 +25,39 @@ calendar.clear(); set( year, month, day ); } + + /** + * Sets the time of the calendar to now. + */ + public Cal now() + { + calendar.setTime( new Date() ); + return this; + } + + /** + * Adds the given amount of time to the given calendar field. + * + * @param field the calendar field. + * @param value the amount of time. + */ + public Cal add( int field, int amount ) + { + calendar.add( field, amount ); + return this; + } + + /** + * Subtracts the given amount of time to the given calendar field. + * + * @param field the calendar field. + * @param value the amount of time. + */ + public Cal subtract( int field, int amount ) + { + calendar.add( field, amount * -1 ); + return this; + } /** * Returns the value of the given calendar field. === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ReportResource.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ReportResource.java 2011-10-12 17:32:39 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/web/api/resources/ReportResource.java 2011-10-23 13:02:22 +0000 @@ -1,8 +1,9 @@ package org.hisp.dhis.web.api.resources; +import static java.util.Calendar.MONTH; + import java.io.IOException; import java.io.OutputStream; -import java.util.Date; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -16,6 +17,7 @@ import org.hisp.dhis.i18n.I18nManager; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Cal; import org.hisp.dhis.report.Report; import org.hisp.dhis.report.ReportService; import org.hisp.dhis.system.util.CodecUtils; @@ -72,7 +74,8 @@ public void write( OutputStream out ) throws IOException, WebApplicationException { - reportService.renderReport( out, report, new Date(), organisationUnitId, ReportService.REPORTTYPE_PDF, format ); + reportService.renderReport( out, report, new Cal().now().subtract( MONTH, 1 ).time(), + organisationUnitId, ReportService.REPORTTYPE_PDF, format ); } } ).build(); }