Switch to full style
General Java code examples
Post a reply

convert XMLGregorianCalendar to GregorianCalendar

Mon Apr 22, 2013 11:43 pm

convert XMLGregorianCalendar to GregorianCalendar and vice versa
java code
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;
}

}




Post a reply
  Related Posts  to : convert XMLGregorianCalendar to GregorianCalendar
 How to Convert WMV to AVI on Mac     -  
 Convert To Upper Case in C++     -  
 Convert String to Date     -  
 convert pascal code to c ?     -  
 convert timestamp using javascript     -  
 convert hexadecimal to decimal     -  
 Convert outputstream to inputstream     -  
 convert word, Excel to PDF     -  
 convert lowercase to uppercase     -  

Topic Tags

Java Time