Code example for DatatypeFactory

Methods: newXMLGregorianCalendar

0
    public static String longToDateTime(final long dateTime) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
        calendar.setTimeInMillis(dateTime);
 
        return dataTypeFactory.newXMLGregorianCalendar(calendar).normalize().toXMLFormat();
    } 
 
    /** 
     * Converts a duration in milliseconds to a lexical duration, as defined by XML Schema 1.0. 
     *  
     * @param duration the duration 
     *  
     * @return the lexical representation 
     */ 
    public static String longToDuration(final long duration) {
        return dataTypeFactory.newDuration(duration).toString();
    } 
 
    static { 
        try {