get XMLGregorianCalendar - Java XML

Java examples for XML:XML Calendar

Description

get XMLGregorianCalendar

Demo Code


//package com.java2s;
import java.util.GregorianCalendar;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class Main {
    public static void main(String[] argv) throws Exception {
        long timeInMillis = 2;
        System.out.println(getCalendar(timeInMillis));
    }//from  w  ww.jav a2  s  . c  o m

    public static XMLGregorianCalendar getCalendar(long timeInMillis)
            throws DatatypeConfigurationException {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(timeInMillis);
        return DatatypeFactory.newInstance().newXMLGregorianCalendar(
                calendar);
    }
}

Related Tutorials