jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: XPath search with date function embbeded......
Date Tue, 15 May 2007 20:00:33 GMT
Hi,

On 5/15/07, hsp_ <piccinatto@ibest.com.br> wrote:
> I need to do a search that compare the value in a date propertie adding a
> constant to this propertie, something like this:
> //element(*,nt:base)[ (@prop:date + xs:dateTime('"+dateContant+"') ) <
> xs:dateTime('"+today+"')]";
>
> My dificult is on: (@prop:date + xs:dateTime('"+dateContant+"') )
> because the comparison ' <  xs:dateTime('"+today+"') ' is ok for only a
> propertie.
>
> Would my query be possible?

How about an approach like the following:

    // Calculate the query date, in this case three days before today
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -3);

    // Format the date as an ISO 8601 string (ValueFactory is our friend!)
    ValueFactory factory = session.getValueFactory();
    String iso8601 = factory.createValue(calendar).getString();

    // Generate the query string (//* is equivalent to //element(*,nt:base))
    String query = "//*[@prop:date < xs:dateTime(" + iso8601 + ")]";

BR,

Jukka Zitting

Mime
View raw message