Search in sources :

Example 21 with Duration

use of javax.xml.datatype.Duration in project webtools.sourceediting by eclipse.

the class XSDateTime method minusXSDayTimeDuration.

private ResultSequence minusXSDayTimeDuration(Item at) {
    XSDuration val = (XSDuration) at;
    try {
        XSDateTime res = (XSDateTime) clone();
        XMLGregorianCalendar xmlCal = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) calendar());
        Duration dtduration = _datatypeFactory.newDuration(val.getStringValue());
        xmlCal.add(dtduration.negate());
        res = new XSDateTime(xmlCal.toGregorianCalendar(), res.tz());
        return ResultSequenceFactory.create_new(res);
    } catch (CloneNotSupportedException ex) {
    }
    return null;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Duration(javax.xml.datatype.Duration)

Example 22 with Duration

use of javax.xml.datatype.Duration in project webtools.sourceediting by eclipse.

the class XSDateTime method minusXSDateTime.

private ResultSequence minusXSDateTime(ResultSequence arg) throws DynamicError {
    XSDateTime val = (XSDateTime) NumericType.get_single_type(arg, XSDateTime.class);
    Calendar thisCal = normalizeCalendar(calendar(), tz());
    Calendar thatCal = normalizeCalendar(val.calendar(), val.tz());
    long duration = thisCal.getTimeInMillis() - thatCal.getTimeInMillis();
    Duration dtduration = _datatypeFactory.newDuration(duration);
    return ResultSequenceFactory.create_new(XSDayTimeDuration.parseDTDuration(dtduration.toString()));
}
Also used : GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Calendar(java.util.Calendar) Duration(javax.xml.datatype.Duration)

Example 23 with Duration

use of javax.xml.datatype.Duration in project webtools.sourceediting by eclipse.

the class XSDate method minusXSDate.

private ResultSequence minusXSDate(ResultSequence arg) throws DynamicError {
    XSDate val = (XSDate) NumericType.get_single_type(arg, XSDate.class);
    Duration dtduration = null;
    Calendar thisCal = normalizeCalendar(calendar(), tz());
    Calendar thatCal = normalizeCalendar(val.calendar(), val.tz());
    long duration = thisCal.getTimeInMillis() - thatCal.getTimeInMillis();
    dtduration = _datatypeFactory.newDuration(duration);
    return ResultSequenceFactory.create_new(XSDayTimeDuration.parseDTDuration(dtduration.toString()));
}
Also used : GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Calendar(java.util.Calendar) Duration(javax.xml.datatype.Duration)

Example 24 with Duration

use of javax.xml.datatype.Duration in project webtools.sourceediting by eclipse.

the class XSDate method minusXSDayTimeDuration.

private ResultSequence minusXSDayTimeDuration(AnyType at) {
    XSDuration val = (XSDuration) at;
    try {
        XSDate res = (XSDate) clone();
        XMLGregorianCalendar xmlCal = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) calendar());
        Duration dtduration = _datatypeFactory.newDuration(val.getStringValue());
        xmlCal.add(dtduration.negate());
        res = new XSDate(xmlCal.toGregorianCalendar(), res.tz());
        return ResultSequenceFactory.create_new(res);
    } catch (CloneNotSupportedException ex) {
    }
    return null;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Duration(javax.xml.datatype.Duration)

Example 25 with Duration

use of javax.xml.datatype.Duration in project webtools.sourceediting by eclipse.

the class XSTime method minusXSDayTimeDuration.

private ResultSequence minusXSDayTimeDuration(Item at) {
    XSDuration val = (XSDuration) at;
    XSTime res = null;
    try {
        res = (XSTime) clone();
    } catch (CloneNotSupportedException err) {
        return null;
    }
    XMLGregorianCalendar xmlCal = _datatypeFactory.newXMLGregorianCalendar((GregorianCalendar) calendar());
    Duration dtduration = _datatypeFactory.newDuration(val.getStringValue());
    xmlCal.add(dtduration.negate());
    res = new XSTime(xmlCal.toGregorianCalendar(), res.tz());
    return ResultSequenceFactory.create_new(res);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Duration(javax.xml.datatype.Duration)

Aggregations

Duration (javax.xml.datatype.Duration)110 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)50 Test (org.junit.Test)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)12 ArrayList (java.util.ArrayList)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)8 GregorianCalendar (java.util.GregorianCalendar)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 Date (java.util.Date)7 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)6 Calendar (java.util.Calendar)6 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)5 XSDayTimeDuration (org.eclipse.wst.xml.xpath2.processor.internal.types.XSDayTimeDuration)5 Collection (java.util.Collection)4 NodeValue (org.apache.jena.sparql.expr.NodeValue)4 NotNull (org.jetbrains.annotations.NotNull)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 Task (com.evolveum.midpoint.task.api.Task)3