use of javax.xml.datatype.Duration in project cxf by apache.
the class FiqlSearchConditionBuilderTest method testNotEqualToDuration.
@Test
public void testNotEqualToDuration() throws ParseException, DatatypeConfigurationException {
Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
String ret = b.is("foo").notEqualTo(d).query();
assertEquals("foo!=-P0Y0M1DT12H0M0S", ret);
}
use of javax.xml.datatype.Duration in project cxf by apache.
the class FiqlSearchConditionBuilderTest method testGreaterThanDuration.
@Test
public void testGreaterThanDuration() throws DatatypeConfigurationException {
Duration d = DatatypeFactory.newInstance().newDuration(false, 0, 0, 1, 12, 0, 0);
String ret = b.is("foo").after(d).query();
assertEquals("foo=gt=-P0Y0M1DT12H0M0S", ret);
}
use of javax.xml.datatype.Duration in project wikidata-query-rdf by wikimedia.
the class WikibaseDateUnitTest method durations.
@Test
public void durations() throws DatatypeConfigurationException {
WikibaseDate wbDate = new WikibaseDate(2016, 8, 5, 0, 0, 0);
Duration d = DatatypeFactory.newInstance().newDuration("P7D");
WikibaseDate wdDate7days = wbDate.addDuration(d);
assertThat(wdDate7days.secondsSinceEpoch()).isEqualTo(jodaSeconds(2016, 8, 12, 0, 0, 0));
wdDate7days = wbDate.addDuration(d.negate());
assertThat(wdDate7days.secondsSinceEpoch()).isEqualTo(jodaSeconds(2016, 7, 29, 0, 0, 0));
}
use of javax.xml.datatype.Duration in project keycloak by keycloak.
the class XMLTimeUtil method add.
/**
* Add additional time in miliseconds
*
* @param value calendar whose value needs to be updated
* @param millis
*
* @return calendar value with the addition
*/
public static XMLGregorianCalendar add(XMLGregorianCalendar value, long millis) {
if (value == null) {
return null;
}
XMLGregorianCalendar newVal = (XMLGregorianCalendar) value.clone();
if (millis == 0) {
return newVal;
}
Duration duration;
duration = DATATYPE_FACTORY.get().newDuration(millis);
newVal.add(duration);
return newVal;
}
use of javax.xml.datatype.Duration in project tck by dmn-tck.
the class CamundaTCKTest method getValue.
private Object getValue(ValueType valueType) {
final JAXBElement<Object> value = valueType.getValue();
final JAXBElement<ValueType.List> listValue = valueType.getList();
final List<Component> componentValue = valueType.getComponent();
if (value == null && listValue == null && componentValue == null) {
return null;
}
if (listValue != null) {
final List<Object> list = new ArrayList<>();
for (ValueType item : listValue.getValue().getItem()) {
list.add(getValue(item));
}
return list;
}
if (componentValue != null && !componentValue.isEmpty()) {
final Map<String, Object> context = new HashMap<>();
for (Component component : componentValue) {
final Object compValue = getValue(component);
context.put(component.getName(), compValue);
}
return context;
}
if (value instanceof Node) {
final Node node = (Node) value;
final String text = node.getFirstChild().getTextContent();
if ("true".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text)) {
return Boolean.valueOf(text);
}
try {
return Long.valueOf(text);
} catch (NumberFormatException e) {
}
try {
return Double.valueOf(text);
} catch (NumberFormatException e) {
}
return text;
}
if (value != null) {
final Object singleValue = value.getValue();
if (singleValue instanceof XMLGregorianCalendar) {
return transformDateTime((XMLGregorianCalendar) singleValue);
}
if (singleValue instanceof Duration) {
return transformDuration((Duration) singleValue);
}
if (singleValue instanceof String[]) {
String[] array = (String[]) singleValue;
return Arrays.asList(array);
}
return singleValue;
}
throw new RuntimeException(String.format("Unexpected value: '%s'", valueType));
}
Aggregations