[
https://issues.apache.org/jira/browse/JENA-1402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16245424#comment-16245424
]
Andy Seaborne commented on JENA-1402:
-------------------------------------
A good suggestion although we have we have found in the past that changes tend
to break some existing users/applications - the number of deployments of Jena
mean that small corner cases show up.
"09:00:00" becomes "09:00" is wrong by XSD. An {{xsd:time}} is "HH:MM:SS" and
optional fractions of a second and optional TZ.
The advantage of the XML* versions is that they (should!) track the XSD details
exactly. java.time looks good for the value representation.
Changes that reach the API need to balance the impact on users/applications to
judge whether the benefit outweighs the impact. The Java 8 documentation has
the mappings in the [package javadoc
javax.xml.datatype|https://docs.oracle.com/javase/8/docs/api/javax/xml/datatype/package-summary.html].
I hope that the bug is fixed soon else the way forward is to replace in
{{Duration}} in {{NodeValueDuration}} with the java.time one, and see that
change propagate through the code, which is mostly {{NodeValueOps}} and
{{XSDFuncOp}}.
> Subtracting two xsd:Duration gives incorrect results in SPARQL query
> --------------------------------------------------------------------
>
> Key: JENA-1402
> URL: https://issues.apache.org/jira/browse/JENA-1402
> Project: Apache Jena
> Issue Type: Bug
> Components: ARQ
> Affects Versions: Jena 3.4.0
> Reporter: Greg Albiston
>
> There is an issue when subtracting two xsd:durations that include:
> * decimal seconds
> * non-zero minutes
> * second operand has a greater number of seconds than the first operand, i.e.
> the minutes are reduced.
> The result is a large number of minutes and incorrect seconds.
> For example:
> Integer, Larger: "PT2M3S" - "PT1M10S" = "PT0M53S" CORRECT
> Decimal, Smaller: "PT2M3.123S" - "PT1M1.123S" = "PT1M2.000S" CORRECT
> Decimal, Larger, Seconds: "PT0M3.123S" - "PT1M10.123S" = "-PT1M7.000S"
> CORRECT
> Decimal, Larger, Minutes: "PT2M3.123S" - "PT1M10.123S" = "PT883M0.020S"
> INCORRECT
> Decimal, Larger, Hours: "PT1H4M3.123S" - "PT0M10.123S" = "PT1H3883M0.020S"
> INCORRECT
> Example SPARQL:
> {code:sparql}
> SELECT ?res ?op1 ?op2
> WHERE{
> VALUES (?op1 ?op2) {
> ("PT2M3S"^^<http://www.w3.org/2001/XMLSchema#duration>
> "PT1M10S"^^<http://www.w3.org/2001/XMLSchema#duration>)
> ("PT2M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration>
> "PT1M1.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
> ("PT0M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration>
> "PT1M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
> ("PT2M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration>
> "PT1M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
> ("PT1H4M3.123S"^^<http://www.w3.org/2001/XMLSchema#duration>
> "PT0M10.123S"^^<http://www.w3.org/2001/XMLSchema#duration>)
> }
> BIND(?op1 - ?op2 AS ?res)
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)