Java examples for XML:XML Calendar
convert SQL Time to Xml Time
//package com.java2s; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import java.sql.Time; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static XMLGregorianCalendar convert2XmlTime(Time time) throws RuntimeException { if (time == null) { throw new IllegalArgumentException("Argument 'Time' is null!"); }/* w ww . jav a 2 s .co m*/ GregorianCalendar utilGregorianCalendar = new GregorianCalendar(); utilGregorianCalendar.setTimeInMillis(time.getTime()); try { return DatatypeFactory.newInstance() .newXMLGregorianCalendarTime( utilGregorianCalendar.get(Calendar.HOUR), utilGregorianCalendar.get(Calendar.MINUTE), utilGregorianCalendar.get(Calendar.SECOND), DatatypeConstants.FIELD_UNDEFINED); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); } } }