I noticed that this will get the job done but does that mean there is no 
shortcut to just inject a java.util.Date and handle it properly?

parQuery.setLiteral("productStatusDate", "2012-01-03", XSDDatatype.XSDdate);

Robby

-----Original Message-----
From: Robby Pelssers [mailto:robby.pelss...@nxp.com] 
Sent: Thursday, August 16, 2012 4:29 PM
To: users@jena.apache.org
Subject: how to parameterize a date in a parametrized query?

Hi all,

Still having a bit of difficulty getting the sparql query to use a xs:date 
instead of xs:dateTime

In RDF we defined a productStatusDate  as follows:
<nxp:productStatusDate 
rdf:datatype="http://www.w3.org/2001/XMLSchema#date";>2011-10-28</nxp:productStatusDate>


I have following query and from Java  I want to filter out all products having 
a specific productStatusDate

#Query showcasing how to select typenumber and preflabel for all products
#having a specific productStatusDate
PREFIX nxp:   <http://purl.org/nxp/schema/v1/>
SELECT ?typeNumber
WHERE
{
  ?x nxp:typeNumber ?typeNumber;
       nxp:productStatusDate ?productStatusDate .
}


I only noticed a setLiteral for Calendar but that does not seem to get the job 
done:

        ParameterizedSparqlString parQuery = new 
ParameterizedSparqlString(sQuery);
        Calendar calendar = Calendar.getInstance();
        calendar.set(2011, 10, 28, 0, 0, 0);    //2011-10-28
        parQuery.setLiteral("productStatusDate", calendar);
        Query query = parQuery.asQuery();
        System.out.println(query.toString());

I printed the query which looks like this:

PREFIX  nxp:  <http://purl.org/nxp/schema/v1/>

SELECT  ?typeNumber
WHERE
  { ?x nxp:typeNumber ?typeNumber .
    ?x nxp:productStatusDate 
"2011-11-27T23:00:00.663Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>
  }


How can I switch to using date ??

Thx in advance,
Robby

Reply via email to