Code example for XMLGregorianCalendar

Methods: getHourtoGregorianCalendar

0
	@Test 
	public void testXmlToSqlDateConverion() throws Exception { 
		DatatypeFactory dataTypeFactory = DatatypeFactory.newInstance();
		XMLGregorianCalendar cal = dataTypeFactory
				.newXMLGregorianCalendar("2004-07-15T00:00:00.000-04:00");
		System.out.println("XMLCalendar Hour " + cal.getHour()
				+ " Gregorian calendar hour " 
				+ cal.toGregorianCalendar().get(Calendar.HOUR_OF_DAY));
		SimpleDateFormat dateFormat = new SimpleDateFormat(
				"dd-MMM-yyyy HH:mm:ss"); 
		System.out.println("SimpleDate Format "
				+ dateFormat.format(cal.toGregorianCalendar().getTime())
				+ " orginal XML string " + "2004-07-15T00:00:00.000-04:00"); 
		System.out.println("DateFormat Format "
				+ DateFormat.getInstance().format(
						cal.toGregorianCalendar().getTime()));
	} 
 
}