Hey, I have datetime components as 3 separate literals, with xsd:gYear, xsd:gMonth, xsd:gDay respective datatypes. Not all mandatory - the format can be YYYY, YYYY-MM, YYYY-MM-DD.
Now how do I combine those into a single xsd:dateTime Literal? A concrete use case would be converting time:inDateTime values into time:inXSDDateTime values: http://www.w3.org/TR/owl-time/#calclock I came up with the code below which seems to work but is not pretty (and doesn't deal with time). I also looked at DateTimeStruct but either way there seemed to be some datatype mismatch. I think it would make more sense for DateTimeStruct to use the builder pattern instead of static methods. Is there a better way? if (resource.hasProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#inDateTime"))) { Calendar calendar = Calendar.getInstance(); Resource dateTimeDesc = resource.getPropertyResourceValue(ResourceFactory.createProperty("http://www.w3.org/2006/time#inDateTime")); if (dateTimeDesc.hasProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#year"))) { RDFNode object = dateTimeDesc.getProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#year")).getObject(); if (object.isLiteral()) { Literal literal = object.asLiteral(); calendar.set(Calendar.YEAR, Integer.parseInt(literal.getLexicalForm())); } } else throw new DateTimeParseException("time:year value is missing"); if (dateTimeDesc.hasProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#month"))) { RDFNode object = dateTimeDesc.getProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#month")).getObject(); if (object.isLiteral()) { Literal literal = object.asLiteral(); calendar.set(Calendar.MONTH, Integer.parseInt(literal.getLexicalForm())); } } if (dateTimeDesc.hasProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#day"))) { RDFNode object = dateTimeDesc.getProperty(ResourceFactory.createProperty("http://www.w3.org/2006/time#day")).getObject(); if (object.isLiteral()) { Literal literal = object.asLiteral(); calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(literal.getLexicalForm())); } } calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Literal dateTime = resource.getModel().createTypedLiteral(calendar); resource.addLiteral(ResourceFactory.createProperty("http://www.w3.org/2006/time#inXSDDateTime"), dateTime); } Martynas graphityhq.com