List of usage examples for javax.xml.datatype XMLGregorianCalendar getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:ejava.projects.edmv.xml.EDmvParserTest.java
public void testMonthParse() throws Exception { log.info("*** testCalendar ***"); DatatypeFactory dataFactory = DatatypeFactory.newInstance(); log.info("DataTypeFactory=" + dataFactory); XMLGregorianCalendar cal = dataFactory.newXMLGregorianCalendar(); log.info("XMLGregorianCalendar=" + cal.getClass()); cal.setMonth(GregorianCalendar.MARCH); String xml = cal.toXMLFormat(); log.debug("cal=" + xml); dataFactory.newXMLGregorianCalendar(xml); cal.setTimezone(0);//w w w. jav a 2s.c o m String format = "--01"; try { XMLGregorianCalendar xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); format = "--01--"; xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); } catch (Exception ex) { log.error("failed to parse:" + format); fail("failed to parse:" + format); } }
From source file:ejava.projects.edmv.xml.EDmvBindingTest.java
public void testCalendar() throws Exception { log.info("*** testCalendar ***"); DatatypeFactory dataFactory = DatatypeFactory.newInstance(); log.info("DataTypeFactory=" + dataFactory); XMLGregorianCalendar cal = dataFactory.newXMLGregorianCalendar(); log.info("XMLGregorianCalendar=" + cal.getClass()); cal.setMonth(GregorianCalendar.MARCH); String xml = cal.toXMLFormat(); log.debug("cal=" + xml); dataFactory.newXMLGregorianCalendar(xml); cal.setTimezone(0);/*from w w w .ja v a 2s . com*/ Calendar jCal = Calendar.getInstance(); jCal.clear(); jCal.set(Calendar.MONTH, Calendar.MARCH); DateFormat df = DateFormat.getDateInstance(); String dfString = df.format(jCal.getTime()); log.debug("calendar=" + dfString); String format = "--01"; try { XMLGregorianCalendar xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); format = "--01--"; xCal = dataFactory.newXMLGregorianCalendar(format); log.info("successfully parsed:" + format + ", xCal=" + xCal.toXMLFormat()); } catch (Exception ex) { log.error("failed to parse:" + format); fail("failed to parse:" + format); } }