1

The odata4j AppEngineConsumerExample demonstrates how to filter entities on string and numeric values with code similar to the following:

reportEntity("\nNon-discontinued product with reorderLevel > 25 (two filter predicates): " , 
            c.getEntities("Product")
            .filter("reorderLevel gt 25 and discontinued eq false")
            .top(1)
            .execute().first());

I'm fairly new to Java (my background is .NET/C#), but the above makes sense. However, I'm unsure how to do something similar for dates. The dates coming from my WCF OData service are formatted as "yyyy-MM-dd'T'HH:mm:ss".

Thanks in advance for your help!

Emre Yazici
  • 10,136
  • 6
  • 48
  • 55
Andy Dyer
  • 506
  • 6
  • 20

1 Answers1

2

It turns out this is a function of OData itself rather than odata4j. The string passed to the filter function in odata4j is the same expression that would be passed via a URL. I found tons of filter examples on the Netflix OData Catalog page.

To filter dates, use something like this:

reportEntity("\nProduct with order date greater than March 1, 2010: " , 
        c.getEntities("Product")
        .filter("OrderDate gt datetime'2010-03-01'")
        .top(1)
        .execute().first());
Andy Dyer
  • 506
  • 6
  • 20
  • Glad to hear you got this working. Seems like a a syntax for providing literal parameters would have been useful here. Or a query builder api. What do you think? – John Spurlock Oct 17 '10 at 21:31