Java Utililty Methods XML Duration Add

List of utility methods to do XML Duration Add

Description

The list of methods to do XML Duration Add are organized into topic(s).

Method

Durationadd(Duration d1, Duration d2)
Add one Duration to another, avoiding the runtime library bug that gives incorrect results when using decimal seconds.
boolean sign1 = d1.getSign() >= 0;
boolean sign2 = d2.getSign() >= 0;
if (sign1 && sign2)
    return addPositiveDurations(d1, d2);
if (!sign1 && !sign2)
    return addPositiveDurations(d1.negate(), d2.negate()).negate();
if (sign1 && !sign2)
    return subtract(d1, d2.negate());
...
Durationadd(Duration... durations)
Adds the given list of durations together, returning the result.
Duration result = DATATYPE_FACTORY.newDuration(0);
if (durations != null) {
    for (int i = 0; i < durations.length; i++) {
        if (durations[i] != null) {
            result = result.add(durations[i]);
return result;
ElementaddElement(Element parent, String name)
Adds a child element to the parent.
return addElement(parent, name, null);
voidaddElement(Element parent, String tagName)
Add the element to the parent by the node name
Document doc = parent.getOwnerDocument();
Element child = doc.createElement(tagName);
parent.appendChild(child);
ElementaddElement(final Element parent, final String name, final Object value)
add Element
final Element ele = addElement(parent, name);
if (value != null) {
    ele.setTextContent(value.toString());
return ele;
ElementaddElement(Node parent, String elementName)
Add an Element node to the supplied parent name.
Element element = null;
if (parent instanceof Document) {
    element = ((Document) parent).createElement(elementName);
} else {
    element = parent.getOwnerDocument().createElement(elementName);
parent.appendChild(element);
return element;
...
ElementaddElement(Node parent, String name)
add Element
Element node;
if (parent.getOwnerDocument() != null)
    node = parent.getOwnerDocument().createElement(name);
else if (parent instanceof Document)
    node = ((Document) parent).createElement(name);
else
    return null;
parent.appendChild(node);
...
ElementaddElement(String name, Element parent)
add Element
Element e = parent.getOwnerDocument().createElement(name);
parent.appendChild(e);
return e;
ElementaddElementFirst(final Element parent, final String name)
Create a new element and add it as the first child
final Element ele = parent.getOwnerDocument().createElement(name);
parent.insertBefore(ele, null);
return ele;
ElementaddElementFirst(final Element parent, final String name)
add Element First
final Element ele = parent.getOwnerDocument().createElement(name);
parent.insertBefore(ele, null);
return ele;