Search in sources :

Example 1 with DateTimeElement

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;
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) Serializable(java.io.Serializable) DateTimeElement(ddf.catalog.transformer.xml.binding.DateTimeElement) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Date(java.util.Date)

Aggregations

DateTimeElement (ddf.catalog.transformer.xml.binding.DateTimeElement)1 Serializable (java.io.Serializable)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1