date getting generated with incorrect format

0 views
Skip to first unread message

Tze-John Tang

unread,
Mar 3, 2015, 3:18:16 PM3/3/15
to sta...@clarkparsia.com
I am using the GraphBuilder to build up a graph before I add it to the triple store. This code was working fine in 2.1.x, and now I am using 2.2.4.  Also, I am using the HTTP protocol, as I had issues with the deadlock when using the SNARL protocol.

GraphBuilder loadDateBuilder = new GraphBuilder();
Date loadDate = Calendar.getInstance().getTime();
loadDateBuilder
.uri(subjectUri).addProperty(IRdfServiceSchema.loadDate, loadDate);

Then, I am adding this graph into the store. Conn is a Connection.

conn.begin();
conn
.add().graph(loadDateBuilder.graph(), contextUri);
conn
.commit();

I am getting the following exception.

13:52:53.785 [DEBUG] org.apache.http.wire |  << "'2015-03-03T13:52:53.319-06:00' is not a valid value for datatype http://www.w3.org/2001/XMLSchema#date [line 25]"

The exception is correct, the value is not a date, but a date / time. Is there any way for me to workaround this?

Thanks,

-tj

Evren Sirin

unread,
Mar 3, 2015, 5:19:44 PM3/3/15
to Stardog
This looks like a bug in GraphBuilder. As a workaround you could
create and pass the literal directly to graph builder as in:

loadDateBuilder.uri(subjectUri).addProperty(IRdfServiceSchema.loadDate,
StardogValueFactory.instance().createLiteral(loadDate));

This will create a valid xsd:dateTime value. If you would like to
create other types, e.g. xsd:date or xsd:time, you can create an
appropriate XMLGregorianCalendar instance and pass that to
createLiteral function instead of the Date value.

Best,
Evren
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com
> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Tze-John Tang

unread,
Mar 4, 2015, 3:37:34 PM3/4/15
to sta...@clarkparsia.com
Thanks Evren.  That worked for me.

-tj
Reply all
Reply to author
Forward
0 new messages