Here you can find the source of toXMLGregorianCalendar(String stringTypeDate)
public static XMLGregorianCalendar toXMLGregorianCalendar(String stringTypeDate) 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; public class Main { public static XMLGregorianCalendar toXMLGregorianCalendar(String stringTypeDate) throws DatatypeConfigurationException { String yyyy = stringTypeDate.substring(0, 4); String mm = stringTypeDate.substring(5, 7); String dd = stringTypeDate.substring(8, 10); String hh = stringTypeDate.substring(11, 13); String mi = stringTypeDate.substring(14, 16); String ss = stringTypeDate.substring(17, 19); int iyyyy = Integer.parseInt(yyyy); int imm = Integer.parseInt(mm); int idd = Integer.parseInt(dd); int ihh = Integer.parseInt(hh); int imi = Integer.parseInt(mi); int iss = Integer.parseInt(ss); DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance(); return dataTypeFactory.newXMLGregorianCalendar(iyyyy, imm, idd, ihh, imi, iss, 0, 0); }/*from w w w . jav a 2 s . c o m*/ }