Code example for DatatypeFactory

Methods: newXMLGregorianCalendar

    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));
Connect your IDE to all the code out there  Get Codota for Java