I am not sure what you are trying to accomplish with your example code.
If you want an event to repeat every Independence Day, then call the
Independence Day temporal expression's first method, and then call the
next method using the returned Calendar. You can call the next method
for as many years as you like. There is no need to increment the date
outside of the temporal expression.
So, calling the first method with a Calendar initialized to 06/01/2011
will return 07/04/2011. Calling the next method with 07/04/2011 will
return 07/04/2012, and so on...
In other words, the Calendar returned by the temporal expression is
supposed to be used as a parameter for the expression's next method.
-Adrian
On 12/4/2011 4:17 PM, Craig Ambrose wrote:
Thanks Adrian. But that doesn't seem to give the expected results either.
Here is what I switched to:
com.ibm.icu.util.Calendar cal = new com.ibm.icu.util.GregorianCalendar();
java.util.Date start = UtilDateTime.toDate("06/01/2011 00:00:00");
cal.setTime(start);
GenericValue temporalExpression = delegator.findOne("TemporalExpression",
UtilMisc.toMap("tempExprId", "INDEPENDENCE_DAY"), true);
TemporalExpression selectionDeadline =
TemporalExpressionWorker.makeTemporalExpression(delegator,
temporalExpression);
for (int index = 0; index< 60; index++)
{
com.ibm.icu.util.Calendar first = selectionDeadline.first(cal);
Date nextDate = new
Date(selectionDeadline.next(first).getTimeInMillis());
Debug.logInfo(String.format("%s -> %s -> %s",
UtilDateTime.toDateString(new Date(cal.getTimeInMillis())),
UtilDateTime.toDateString(new Date(first.getTimeInMillis())),
UtilDateTime.toDateString(nextDate)),
"Groovy");
cal.add(com.ibm.icu.util.Calendar.DATE, 1);
}
With calling te.first() and passing the result to te.next(). It always
outputs 7/4/2012.
Perhaps I need to check the result of te.first() first? Like this:
for (int index = 0; index< 60; index++)
{
com.ibm.icu.util.Calendar first = selectionDeadline.first(cal);
com.ibm.icu.util.Calendar nextCal;
if (first> cal)
{
nextCal = first
}
else
{
nextCal = selectionDeadline.next(first);
}
Debug.logInfo(String.format("%s -> %s -> %s",
UtilDateTime.toDateString(new Date(cal.getTimeInMillis())),
UtilDateTime.toDateString(new Date(first.getTimeInMillis())),
UtilDateTime.toDateString(new Date(nextCal.getTimeInMillis()))),
"Groovy");
cal.add(com.ibm.icu.util.Calendar.DATE, 1);
}
Is that the intended use?
Thanks for your timely response.
-craig
--
View this message in context:
http://ofbiz.135035.n4.nabble.com/Do-Intersection-TemporalExpressions-work-tp4155989p4157247.html
Sent from the OFBiz - User mailing list archive at Nabble.com.