1 package ejava.projects.eleague.xml; 2 3 import java.util.Calendar; 4 import java.util.Date; 5 import java.util.GregorianCalendar; 6 7 import javax.xml.bind.DatatypeConverter; 8 9 /** 10 * This class will convert the dateTime strings from XML documents to/from 11 * java.util.Date instead of the default XMLGregorianCalendar. 12 */ 13 public class DateConverter { 14 public static Date parseDate(String s) { 15 return DatatypeConverter.parseDate(s).getTime(); 16 } 17 public static String printDate(Date dt) { 18 Calendar cal = new GregorianCalendar(); 19 cal.setTime(dt); 20 return DatatypeConverter.printDateTime(cal); 21 } 22 }