System.setProperty("drools.dateformat","dd MM yyyy") doesnt works for me in drools 5.6

1,415 views
Skip to first unread message

nmsund...@gmail.com

unread,
Sep 1, 2014, 2:54:09 AM9/1/14
to drools...@googlegroups.com
Hi guys,

System.setProperty("drools.dateformat","dd MM yyyy") doesnt works of me in drools 5.6 , which was working fine in drools5.5 .

Do I need to do additional changes in drools 5.6 to make it work .



nmsund...@gmail.com

unread,
Sep 1, 2014, 4:45:16 AM9/1/14
to drools...@googlegroups.com
Hi guys,

Below is the stacktrace of the error i faced

"Caused by: java.lang.IllegalArgumentException: Invalid date input format: [08/01/2013] it should follow: [dd-MMM-yyyy]"

Michael Anstis

unread,
Sep 1, 2014, 4:47:42 AM9/1/14
to drools...@googlegroups.com
Now I can't say for sure with the limited information you've given, but it looks to me as though a String date value cannot be parsed with the date format you provide.

"Invalid date input format: [08/01/2013]" would expect a date format of dd/MM/yyyy not "dd MM yyyy" as you are setting it.


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/be6e8fe9-2a8f-4a1f-aae0-804b631022ab%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

nmsund...@gmail.com

unread,
Sep 1, 2014, 5:06:02 AM9/1/14
to drools...@googlegroups.com
Hi Michael Anstis,


I need to override default dateformat in drools to "dd MM yyyy" from dd-MMM-yyyy . can you suggest me the approach on that it would be helpful for me .





Michael Anstis

unread,
Sep 1, 2014, 5:08:09 AM9/1/14
to drools...@googlegroups.com
Setting the System Property is a perfectly good way to override the date format.

However you need then to be sure every date (String) value adheres to the format you are configuring.

In your example (so far) with a date format of "dd MM yyyy" the (String) value "08/01/2013" cannot be parsed - as the format contains spaces, but the value contains slashes.



chene...@gmail.com

unread,
Sep 1, 2014, 5:12:36 AM9/1/14
to drools...@googlegroups.com
Hi, I use 5.6. I also use setProperty override dateformat, and is ok.
Did you sure set the date format before load your rules ?

nmsund...@gmail.com

unread,
Sep 1, 2014, 7:20:08 AM9/1/14
to drools...@googlegroups.com
Hi

I had set the dateformat before executing the rules in knowledgebase using System.setProperty("drools.dateformat","dd MM yyyy");.

Do you have any concern on that ? .

please let me know your suggestion on that.

chene...@gmail.com

unread,
Sep 1, 2014, 7:52:43 AM9/1/14
to drools...@googlegroups.com
Hi.
It should write before use KnowledgeBuilder add rule content, not just before execute rule.
If not it will throw exception : "Invalid date input format: [01 09 2014] it should follow: [dd-MMM-yyyy]"

By the way , the exception message of your's , "Invalid date input format: [08/01/2013] it should follow: [dd-MMM-yyyy]".
I think you have another mistake, you want data format is "dd MM yyyy", but you write date string "08/01/2013", you should write "08 01 2013" in you rule content.

nmsund...@gmail.com

unread,
Sep 1, 2014, 8:48:24 AM9/1/14
to drools...@googlegroups.com
Hi ,

Thanks for the response .

I have used the date "08/01/2013" in my decision table, My assumption is excel takes the default date format as "dd MM yyyy". So only i am overriding the default dateformat property in drools.

The same was working fine for me with drools 5.5.

Please let me know your suggestion and comment on that.

nmsund...@gmail.com

unread,
Sep 2, 2014, 8:31:07 AM9/2/14
to drools...@googlegroups.com
Hi guys,

I have solved the problem . Dateformat from decision table loaded using drools 5.5 returns in "dd MM yyyy hh.. " format. whereas Dateformat from decision table loaded using drools 5.6 returning in the format that we specified in Decision table.

Thanks for your help :).
Reply all
Reply to author
Forward
0 new messages