|
Jacopo,
FYI: the Calendar roll method is intended to be used by UI artifacts as a type of spinner. In this example, rolling the month increments the month without recalculating the date. Let's say the current date is January 31, 2009, Rolling the month +1 will result in February 31, 2009. That isn't a real date, of course. In contrast, adding +1 to the month will give you February 28, 2009. I hope this helps. -Adrian [hidden email] wrote: > Author: jacopoc > Date: Wed Dec 9 15:06:42 2009 > New Revision: 888825 > > URL: http://svn.apache.org/viewvc?rev=888825&view=rev > Log: > Fixed code that could cause infinite loops. > > Modified: > ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy > > Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy > URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy?rev=888825&r1=888824&r2=888825&view=diff > ============================================================================== > --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy (original) > +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy Wed Dec 9 15:06:42 2009 > @@ -76,7 +76,6 @@ > isPosted = parameters.isPosted; > > while (customTimePeriodEndDate <= currentTimePeriod.thruDate) { > - > if ("ALL".equals(isPosted)) { > isPosted = ""; > } > @@ -97,7 +96,7 @@ > > glAcctgTrialBalanceList.add(acctgTransEntriesAndTransTotal); > > - calendarTimePeriodStartDate.roll(Calendar.MONTH, 1); > + calendarTimePeriodStartDate.add(Calendar.MONTH, 1); > Timestamp retStampStartDate = new Timestamp(calendarTimePeriodStartDate.getTimeInMillis()); > retStampStartDate.setNanos(0); > customTimePeriodStartDate = retStampStartDate; > > > |
|
Adrian,
thank you for the explanation. I actually know the difference between Calendar.add and Calendar.roll, and I fixed the code because we have to jump from month to month in an iteration: November 2009, December 2009, January 2010 and not (as it was happening before my fix): November 2009, December 2009, January 2009 Jacopo On Dec 9, 2009, at 5:09 PM, Adrian Crum wrote: > Jacopo, > > FYI: the Calendar roll method is intended to be used by UI artifacts as a type of spinner. In this example, rolling the month increments the month without recalculating the date. > > Let's say the current date is January 31, 2009, Rolling the month +1 will result in February 31, 2009. That isn't a real date, of course. In contrast, adding +1 to the month will give you February 28, 2009. > > I hope this helps. > > -Adrian > > [hidden email] wrote: >> Author: jacopoc >> Date: Wed Dec 9 15:06:42 2009 >> New Revision: 888825 >> URL: http://svn.apache.org/viewvc?rev=888825&view=rev >> Log: >> Fixed code that could cause infinite loops. >> Modified: >> ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy >> Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy >> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy?rev=888825&r1=888824&r2=888825&view=diff >> ============================================================================== >> --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy (original) >> +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/reports/GlAccountTrialBalance.groovy Wed Dec 9 15:06:42 2009 >> @@ -76,7 +76,6 @@ >> isPosted = parameters.isPosted; >> while (customTimePeriodEndDate <= currentTimePeriod.thruDate) { >> - >> if ("ALL".equals(isPosted)) { >> isPosted = ""; >> } >> @@ -97,7 +96,7 @@ >> glAcctgTrialBalanceList.add(acctgTransEntriesAndTransTotal); >> - calendarTimePeriodStartDate.roll(Calendar.MONTH, 1); >> + calendarTimePeriodStartDate.add(Calendar.MONTH, 1); >> Timestamp retStampStartDate = new Timestamp(calendarTimePeriodStartDate.getTimeInMillis()); >> retStampStartDate.setNanos(0); >> customTimePeriodStartDate = retStampStartDate; |
| Free forum by Nabble | Edit this page |
