Java XML Datatype package

Published: Monday, 31 March 2008

Duration

Sample code to create a Duration

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;

// ...
DatatypeFactory df;
try
{
    df = DatatypeFactory.newInstance();
}
catch (DatatypeConfigurationException e)
{
    throw new RuntimeException(e.getMessage());
}
// 100 day duration
Duration duration = df.newDuration("P100D");