use of javax.xml.datatype.Duration in project cxf by apache.
the class SourceSequence method setExpires.
public void setExpires(Expires ex) {
Duration d = null;
expires = null;
if (null != ex) {
d = ex.getValue();
}
if (null != d && !d.equals(DatatypeFactory.PT0S)) {
Date now = new Date();
expires = new Date(now.getTime() + ex.getValue().getTimeInMillis(now));
}
}
use of javax.xml.datatype.Duration in project cxf by apache.
the class AbstractSubscription method parseTerminationTime.
protected XMLGregorianCalendar parseTerminationTime(String value) {
try {
Duration d = datatypeFactory.newDuration(value);
XMLGregorianCalendar c = getCurrentTime();
c.add(d);
return c;
} catch (Exception e) {
// Ignore
}
try {
Duration d = datatypeFactory.newDurationDayTime(value);
XMLGregorianCalendar c = getCurrentTime();
c.add(d);
return c;
} catch (Exception e) {
// Ignore
}
try {
Duration d = datatypeFactory.newDurationYearMonth(value);
XMLGregorianCalendar c = getCurrentTime();
c.add(d);
return c;
} catch (Exception e) {
// Ignore
}
try {
return datatypeFactory.newXMLGregorianCalendar(value);
} catch (Exception e) {
// Ignore
}
return null;
}
use of javax.xml.datatype.Duration in project cxf by apache.
the class DurationAndDateUtil method toExpirationTypeContainingDuration.
public static ExpirationType toExpirationTypeContainingDuration(XMLGregorianCalendar date) {
ExpirationType et = new ExpirationType();
XMLGregorianCalendar now = factory.newXMLGregorianCalendar(new GregorianCalendar());
XMLGregorianCalendar then = factory.newXMLGregorianCalendar(date.toGregorianCalendar());
long durationMillis = then.toGregorianCalendar().getTimeInMillis() - now.toGregorianCalendar().getTimeInMillis();
Duration duration = factory.newDuration(durationMillis);
et.setValue(duration.toString());
return et;
}
use of javax.xml.datatype.Duration in project cxf by apache.
the class FiqlSearchConditionBuilderTest method testLessThanDuration.
@Test
public void testLessThanDuration() throws DatatypeConfigurationException {
Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
String ret = b.is("foo").before(d).query();
assertEquals("foo=lt=-P0Y0M1DT12H0M0S", ret);
}
use of javax.xml.datatype.Duration in project cxf by apache.
the class FiqlSearchConditionBuilderTest method testEqualToDuration.
@Test
public void testEqualToDuration() throws ParseException, DatatypeConfigurationException {
Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
String ret = b.is("foo").equalTo(d).query();
assertEquals("foo==-P0Y0M1DT12H0M0S", ret);
}
Aggregations