我在 protege 中创建了一个文件系统本体。我已将文件创建日期范围设置为 dateTime,如下面的代码所示。
<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>
在日期创建属性中,我存储java日期Date date = new Date();
(转换为字符串后)
它正确存储为:
<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>
我的问题是:在 XMLSchema#dateTime
中存储 java Date 是否安全/正确?
我这样做是正确还是错误?
最佳答案
这不是 XML 架构日期时间的正确格式值。相反,它应该采用以下格式:
yyyy-MM-dd'T'HH:mm:ss
您可以利用 SimpleDateFormat
控制String
表示或使用 XMLGregorianCalendar
而不是Date
.
关于java - 本体 - 在 XMLSchema 中存储 Java 日期#dateTime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23106154/