Here you can find the source of dateToXmlGregorianCalendar(Date d)
public static XMLGregorianCalendar dateToXmlGregorianCalendar(Date d)
//package com.java2s; /*/*from w w w . ja v a 2 s .c o m*/ * GovPay - Porta di Accesso al Nodo dei Pagamenti SPC * http://www.gov4j.it/govpay * * Copyright (c) 2014-2015 Link.it srl (http://www.link.it). * Copyright (c) 2014-2015 TAS S.p.A. (http://www.tasgroup.it). * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class Main { private static DatatypeFactory datatypeFactory; public static XMLGregorianCalendar dateToXmlGregorianCalendar(Date d) { if (d == null) { return null; } GregorianCalendar gregory = new GregorianCalendar(); gregory.setTime(d); XMLGregorianCalendar returnValue; returnValue = datatypeFactory.newXMLGregorianCalendar(gregory); return returnValue; } }