[rules-users] accumulate min over java.util.Date
Michael Anstis
michael.anstis at gmail.com
Thu Mar 24 15:40:54 EDT 2011
As Greg eludes to the default "min" accumulate function expects
(java.lang.)Numbers.
If you require one to handle dates you can write your own custom Accumulate
Function.
On 24 March 2011 17:50, Greg Barton <greg_barton at yahoo.com> wrote:
> That's because a java.util.Date is not a java.lang.Number. :) You can get
> the long value behind the Date by calling Date.getTime(), though. Try that.
>
> --- On Thu, 3/24/11, jkrupka <jkrupka at gmail.com> wrote:
>
> > From: jkrupka <jkrupka at gmail.com>
> > Subject: [rules-users] accumulate min over java.util.Date
> > To: rules-users at lists.jboss.org
> > Date: Thursday, March 24, 2011, 12:07 PM
> > Should I be able to do an accumulate
> > min over java.util.Date objects? Like
> > this:
> > $minDate : Date() from accumulate(MyFact ($startDate :
> > startDate),
> >
> > min($startDate))
> >
> > I would have thought so, but when I try it, I'm getting:
> >
> > Caused by: java.lang.ClassCastException: java.util.Date
> > cannot be cast to
> > java.lang.Number
> > at
> >
> org.drools.base.accumulators.MinAccumulateFunction.accumulate(MinAccumulateFunction.java:76)
> >
> >
> >
> > If it should work, then it's possible I'm doing something
> > else wrong, but
> > everything looks correct to me. I can always work
> > around it by getting the
> > milliseconds from the Date object and doing the min over
> > that... it's just
> > not as clean looking.
> >
> > --
> > View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/accumulate-min-over-java-util-Date-tp2726081p2726081.html
> > Sent from the Drools - User mailing list archive at
> > Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110324/6c6607fd/attachment.html
More information about the rules-users
mailing list