0
votes

I am trying to call Drools Json api and one of my facts is of type Date. I am not sure how to construct the json string for that. !!!!????????? :(

here is what I have:

my drl file: package com.beachmint.common

declare Order orderId: Integer customerId: Integer total: java.math.BigDecimal cartId: Integer createdAt: java.util.Date productIds: java.util.ArrayList end

declare Customer customerId: Integer referrerId: Integer customerStatus: Integer createdAt: java.util.Date end

declare Points status: String count: Integer customerId: Integer reason: String ruleId: String end

declare Event name: String storeId: Integer end

rule 'Purchase Promo' dialect "mvel" when e : Event( name matches "Purchase" ) o : Order( total > 0 , createdAt > "08-Oct-2012" , createdAt <= "01-Jan-2013" )

then p.setCount( p.getCount() + 2000 );

I tried sending the date as UTC and string ('y-M-d) format.

createdAt":{"date":"2012-Jan-01"} createdAt": 1351637683 createdAt": "2012-Jan-01"

none of these work :(

1

1 Answers

0
votes

You can either use the default date format or, change it using drools.dateformat system property. See the manual.

4.8.3.3.7.1. Date literal

The date format dd-mmm-yyyy is supported by default. You can customize this by providing an alternative date format mask as the System property named drools.dateformat. If more control is required, use a restriction.

Example 4.36. Date Literal Restriction

Cheese( bestBefore < "27-Oct-2009" )