use of javax.xml.datatype.DatatypeConfigurationException in project sis by apache.
the class UniversalTimeAdapter method marshal.
/**
* Converts the date to the object to be marshalled in a XML file or stream.
* JAXB calls automatically this method at marshalling time.
*
* @param value the {@code java.util} date value, or {@code null}.
* @return the XML date, or {@code null}.
*/
@Override
public XMLGregorianCalendar marshal(final Date value) {
if (value != null) {
final GregorianCalendar calendar = new GregorianCalendar(UTC, Locale.ROOT);
calendar.setTime(value);
try {
final XMLGregorianCalendar gc = XmlUtilities.getDatatypeFactory().newXMLGregorianCalendar(calendar);
if (gc.getMillisecond() == 0) {
gc.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
}
return gc;
} catch (DatatypeConfigurationException e) {
Context.warningOccured(Context.current(), XmlAdapter.class, "marshal", e, true);
}
}
return null;
}
Aggregations