Total members 11893 |It is currently Tue Nov 12, 2024 9:30 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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;
}

}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : convert XMLGregorianCalendar to GregorianCalendar
 How to Convert WMV to AVI on Mac     -  
 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     -  
 convert to binary number     -  
 convert string into binary     -  



Topic Tags

Java Time






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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