Code example for DatatypeFactory

Methods: newDurationnewXMLGregorianCalendar

0
    } 
 
    public static Object parseDurationOrTimestamp(String input) throws IllegalArgumentException {
        Object ret; 
        try { 
            ret = factory.newDuration(input);
        } catch (Exception e) {
            ret = factory.newXMLGregorianCalendar(input);
        } 
        return ret; 
    } 
 
    public static String convertToXMLString(Object input) {
        if (input instanceof XMLGregorianCalendar) {
            return ((XMLGregorianCalendar)input).toXMLFormat();
        } 
        if (input instanceof Duration) {
            return ((Duration)input).toString();
        } 
        throw new IllegalArgumentException(
Contextual code suggestions in your IDE  Get Codota for Java