Mon Apr 22, 2013 11:43 pm
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
import org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl;
public final class DateConverter {
private DateConverter() {
}
/**
* gregorianCalendar conversion
*
*/
private static XMLGregorianCalendar createXmlGregorianCalendar(
GregorianCalendar gregorianCalendar) {
XMLGregorianCalendar xMLGregorianCalendar = null;
try {
xMLGregorianCalendar = DatatypeFactoryImpl.newInstance()
.newXMLGregorianCalendar(gregorianCalendar);
} catch (DatatypeConfigurationException e) {
// do something
}
return xMLGregorianCalendar;
}
/**
* xMLGregorianCalendar
* to be converted to GregorianCalendar
*
*/
private static GregorianCalendar createCalendar(
XMLGregorianCalendar xMLGregorianCalendar) {
return xMLGregorianCalendar.toGregorianCalendar();
}
/*
* Convert the date to Calendar.
*/
public static Calendar createCalendar(Date date) {
Calendar calendar = GregorianCalendar
.getInstance();
calendar.setTime(date);
return calendar;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.