XPathQuery and java.util.Date

I need to query data by datetime field, but it seems java.util.Date is not supported by XPathQuery out of the box – there is no corresponding setVariable​(..) method to set the value for such field. How can I execute query equivalent to this:         List<IMendixObject> results = Core.createXPathQuery("//MYModule.Myentity[MyDatetimeField=$MyDatetimeFieldFilter]")                 .setVariable("MyDatetimeFieldFilter", (java.util.Date) MyDatetimeFieldFilter) //there is no support for Date type                 .execute(getContext()); ? MyDatetimeField is not localised, just in case it matters.
1 answers

variables like $MyDatetimeFieldFilter don't exist in Java. In Java you need to set the date filter as a number value. Beware of the fact that for dates you need a range in most cases.


Long L = MyDatetimeFieldFilter.getTime();

List<IMendixObject> results = Core.createXPathQuery("//MYModule.Myentity[MyDatetimeField=”+ L + “]")