Code example for DatatypeFactory

Methods: newXMLGregorianCalendar

0
     */ 
    public static long dateTimeToLong(final String dateTime) {
        String trimmedString = StringSupport.trimOrNull(dateTime);
        Assert.isNotNull(trimmedString, "Lexical dateTime may not be null or empty");
 
        XMLGregorianCalendar calendar = dataTypeFactory.newXMLGregorianCalendar(dateTime);
        return calendar.toGregorianCalendar().getTimeInMillis();
    } 
 
    /** 
     * Converts a lexical duration, as defined by XML Schema 1.0, into milliseconds. 
     *  
     * @param duration lexical duration representation 
     *  
     * @return duration in milliseconds 
     */ 
    public static long durationToLong(final String duration) {
        return dataTypeFactory.newDuration(duration).getTimeInMillis(new Date(0));
    } 
 
    /**