2
votes

I created a File System ontology in protege. I have set range of file created date as dateTime, as depicted in below code.

<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/administrator/ontologies/2014/2/untitled-ontology-5#created">
  <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
  <rdfs:domain rdf:resource="http://www.semanticweb.org/administrator/ontologies/2014/2/untitled-ontology-5#File"/>
  <rdfs:comment>Time when the file was last accessed.</rdfs:comment>
  <rdfs:label>fileLastAccessed</rdfs:label>

in date create property I am storing java date Date date = new Date(); (after casting to String)

it store correctly as:

<File rdf:about="http://www.semanticweb.org/administrator/ontologies/2014/2/untitled-ontology-5#8117c6b9-3db8-4ab9-8de4-ba67f52ac615">
<created>Wed Apr 16 14:37:30 PKT 2014</created>
<hasPath>/Documents/Untitled Document 5</hasPath>

My question is that: is it safe / correct way to store java Date in XMLSchema#dateTime ?

Am I doing it correctly or wrongly?

1

1 Answers

2
votes

That isn't a correctly formatted value for XML Schema dateTime. Instead it should be in the following format:

yyyy-MM-dd'T'HH:mm:ss

You could leverage a SimpleDateFormat to control the String representation or use XMLGregorianCalendar instead of Date.