Passing dates to microflows from Java

I've got a microflow, one of whose inputs is a Mendix DateTime value (it takes a date and returns a rate taken from the tariff in force on that date). If I call it from Java with code like this: Date completionDate = job.getcompletedDate(); HashMap<String, Object> params = new HashMap<String, Object>(); params.put("InputBranchObject", branch); params.put("InputDateTime", completionDate); double basicRate = (Double) Core.execute (context, "PipsAndSubbies.Branch_getLabourRateForDate", params); setBasicRate (basicRate); the microflow throws this: 2009-10-02 00:18:33.033 ERROR - MICROFLOWENGINE: Exception occurred in microflow 'PipsAndSubbies.Branch_getLabourRateForDate' for activity 'Get labour rate prevailing at given date'', all database changes executed by this microflow were rolled back 2009-10-02 00:18:33.034 ERROR - MICROFLOWENGINE: java.lang.RuntimeException: org.jaxen.XPathSyntaxException: Expected: ] but the microflow works perfectly well when called from within Mendix passing in a Mendix DateTime. The offending XPath occurring in the microflow action is this: //BranchLabourRate [PipsAndSubbies.BranchLabourRate_Branch = $InputBranchObject and labourRateEffectiveDate < $InputDateTime] I'm guessing that the Core is expecting some other class than java.lang.Date, which in any case is deprecated. What's the correct way to pass dates to microflows expecting DateTime inputs?
2 answers

Hi Martin,

The code looks fine. You should pass on a Date object, you are using java.util.Date not java.lang.Date I think?

Could you try to set the log level of CONNECTIONBUS_RETRIEVE (option 7 of the ConsoleMenu ("Set console log level")) to "debug"? In that way you should be able to see what query is executed. We can probably figure out what's wrong if we know what the exact query is.


I think your guess is right. The proxy returns a java.lang.Date object. Instead of passing a lava.lang.Date object try to pass a MendixDateTime object. The way to get the date as a MendixDateTime object is the following:

MendixDateTime dt = job.getMendixObject().getValue(String.valueOf(Job.MemberNames.completedDate));

I'm curious if this solve your problem.