Here you can find the source of dateToXMLGregorianCalendar(Date date)
public static XMLGregorianCalendar dateToXMLGregorianCalendar(Date date) throws DatatypeConfigurationException
//package com.java2s; //License from project: Apache License import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.util.*; public class Main { public static XMLGregorianCalendar dateToXMLGregorianCalendar(Date date) throws DatatypeConfigurationException { if (date == null) return null; return DatatypeFactory.newInstance().newXMLGregorianCalendar(dateToGregorianCalendar(date)); }//from ww w . j av a2 s. c o m public static GregorianCalendar dateToGregorianCalendar(Date date) { if (date == null) return null; GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT+09:00"), Locale.KOREAN); cal.setTime(date); return cal; } }