Code example for DatatypeFactory

Methods: newXMLGregorianCalendar

    public static String longToDateTime(final long dateTime) {
        GregorianCalendar calendar = new GregorianCalendar();
        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 { 
Stop searching for code, let great code find you!  Add Codota to your java IDE