*/
public void setElement(final Duration duration) {
metadata = null; // Cleaned first in case of failure.
if (duration != null) try {
final TemporalFactory factory = TemporalUtilities.getTemporalFactory();
InternationalString years = null;
int value;
if ((value = duration.getYears()) != 0) {
years = new SimpleInternationalString(Integer.toString(value));
}
InternationalString months = null;
if ((value = duration.getMonths()) != 0) {
months = new SimpleInternationalString(Integer.toString(value));
}
InternationalString weeks = null; // no weeks in javax.xml.datatype.Duration
InternationalString days = null;
if ((value = duration.getDays()) != 0) {
days = new SimpleInternationalString(Integer.toString(value));
}
InternationalString hours = null;
if ((value = duration.getHours()) != 0) {
hours = new SimpleInternationalString(Integer.toString(value));
}
InternationalString minutes = null;
if ((value = duration.getMinutes()) != 0) {
minutes = new SimpleInternationalString(Integer.toString(value));
}
InternationalString seconds = null;
if ((value = duration.getSeconds()) != 0) {
seconds = new SimpleInternationalString(Integer.toString(value));
}
metadata = factory.createPeriodDuration(years, months, weeks, days, hours, minutes, seconds);
} catch (UnsupportedOperationException e) {