Java tutorial
//package com.java2s; import javax.xml.datatype.XMLGregorianCalendar; public class Main { public static String toStr(XMLGregorianCalendar xmlGregorianCalendar) { // 1970-01-01 => hour minute secend timezone :-2147483648 String result = ""; result += xmlGregorianCalendar.getYear(); result += "-"; result += zeroize(xmlGregorianCalendar.getMonth()); result += "-"; result += zeroize(xmlGregorianCalendar.getDay()); result += "T"; result += zeroize(xmlGregorianCalendar.getHour()); result += ":"; result += zeroize(xmlGregorianCalendar.getMinute()); result += ":"; result += zeroize(xmlGregorianCalendar.getSecond()); return result; // return new Date(xmlGregorianCalendar.getMillisecond()); } private static String zeroize(int num) { if (num < 10) { return "0" + num; } return "" + num; } }