use of ddf.catalog.transformer.xml.binding.DateTimeElement in project ddf by codice.
the class DateTimeAdapter method marshalFrom.
public static DateTimeElement marshalFrom(Attribute attribute) {
DateTimeElement element = new DateTimeElement();
element.setName(attribute.getName());
if (attribute.getValue() != null) {
for (Serializable value : attribute.getValues()) {
if (!(value instanceof Date)) {
continue;
}
Date date = (Date) value;
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(date);
try {
((DateTimeElement) element).getValue().add(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
} catch (DatatypeConfigurationException e) {
LOGGER.debug("Could not parse Metacard Attribute. XML Date could not be generated.", e);
}
}
}
return element;
}
Aggregations