Refine search
GregorianCalendar c = new GregorianCalendar(); c.setTime(yourDate); XMLGregorianCalendar date2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
public XMLGregorianCalendar createXMLGregorianCalendar(Calendar calendar) { if (dateFactory == null) { try { dateFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new IllegalStateException("Could not obtain an instance of DatatypeFactory.", e); } } return dateFactory.newXMLGregorianCalendar((GregorianCalendar) calendar); }
public XMLGregorianCalendar createXMLGregorianCalendar(Calendar calendar) { if (dateFactory == null) { try { dateFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new IllegalStateException("Could not obtain an instance of DatatypeFactory.", e); } } return dateFactory.newXMLGregorianCalendar((GregorianCalendar) calendar); }
GregorianCalendar gcal = new GregorianCalendar(); start = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal); start.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; public class DateTest { public static void main(final String[] args) throws Exception { GregorianCalendar gcal = new GregorianCalendar(); XMLGregorianCalendar xgcal = DatatypeFactory.newInstance() .newXMLGregorianCalendar(gcal); System.out.println(xgcal); } }
final DateFormat format = new SimpleDateFormat("E. M/d"); final String dateStr = "Thu. 03/01"; final Date date = format.parse(dateStr); GregorianCalendar gregory = new GregorianCalendar(); gregory.setTime(date); XMLGregorianCalendar calendar = DatatypeFactory.newInstance() .newXMLGregorianCalendar( gregory);
javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar("2011-01-01Z").toGregorianCalendar().getTime()
public IsoTimeParameter (String param) { // WMS spec annex D: time is specified in ISO8601:2000 extended // http://stackoverflow.com/questions/2201925/converting-iso8601-compliant-string-to-java-util-date try { cal = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(param).toGregorianCalendar(); } catch (Exception e) { throw new WebApplicationException(fail(param, e)); } }
public Object create(BeanCreationDirective directive) { DatatypeFactory dataTypeFactory; try { dataTypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new MappingException(e); } return dataTypeFactory.newXMLGregorianCalendar(); }
LocalDate date = LocalDate.now(); GregorianCalendar gcal = GregorianCalendar.from(date.atStartOfDay(ZoneId.systemDefault())); XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal);
public <T> T convert(Object source, Class<T> target) throws Exception { if (source instanceof GregorianCalendar) { return (T) DatatypeFactory.newInstance() .newXMLGregorianCalendar((GregorianCalendar) source); } return null; } };
DatatypeFactory .newInstance() .newXMLGregorianCalendar("2012-05-15T07:08:09+03:00");
XMLGregorianCalendar xgc = DatatypeFactory.newInstance().newXMLGregorianCalendar(new DateTime().toGregorianCalendar());
try { DatatypeFactory df = javax.xml.datatype.DatatypeFactory.newInstance(); XMLGregorianCalendar xmlGregCal = df.newXMLGregorianCalendar(time); GregorianCalendar gregCal = xmlGregCal.toGregorianCalendar(); if (xmlGregCal.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
package forum11743306; import javax.xml.bind.*; import javax.xml.datatype.DatatypeFactory; import org.eclipse.persistence.Version; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Root.class); System.out.println(Version.getVersion()); System.out.println(jc.getClass()); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); Root root = new Root(); root.setXyzDate(null); marshaller.marshal(root, System.out); root.setXyzDate(DatatypeFactory.newInstance().newXMLGregorianCalendar("2012-08-01")); marshaller.marshal(root, System.out); } }
Date dob=null; DateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); dob=df.parse( "2014-02-10 11:15:00" ); GregorianCalendar cal = new GregorianCalendar(); cal.setTime(dob); XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH), dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, cal.getTimeZone().LONG).normalize(); XMLGregorianCalendar xmlDate3 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH)+1, cal.get(Calendar.DAY_OF_MONTH),dob.getHours(),dob.getMinutes(),dob.getSeconds(),DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED); System.out.println(xmlDate2); System.out.println(xmlDate3);
XMLGregorianCalendar gTime = null; try { gTime = DatatypeFactory.newInstance().newXMLGregorianCalendar((GregorianCalendar) gc).normalize(); } catch (DatatypeConfigurationException e) { ErrorUtils.RuntimeErrors.ILLEGAL_STATE.throwRuntime("Unable to set the begin time due to", e);
public void testXMLGregorianCalendarToDate() throws Exception { XMLGregorianCalendar gc = DatatypeFactory.newInstance().newXMLGregorianCalendar("1981-06-20T12:00:00"); assertNotNull(factory.createConverter(XMLGregorianCalendar.class, Date.class, null)); Date date = factory.createConverter(XMLGregorianCalendar.class, Date.class, null) .convert(gc, Date.class); assertNotNull(date); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); assertEquals(1981, calendar.get(Calendar.YEAR)); assertEquals(5, calendar.get(Calendar.MONTH)); assertEquals(20, calendar.get(Calendar.DATE)); assertEquals(12, calendar.get(Calendar.HOUR_OF_DAY)); assertEquals(0, calendar.get(Calendar.MINUTE)); assertEquals(0, calendar.get(Calendar.SECOND)); }
public void testXMLGregorianCalendarToCalendar() throws Exception { XMLGregorianCalendar gc = DatatypeFactory.newInstance().newXMLGregorianCalendar("1981-06-20T12:00:00"); assertNotNull(factory.createConverter(XMLGregorianCalendar.class, Calendar.class, null)); Calendar calendar = (Calendar) factory.createConverter(XMLGregorianCalendar.class, Calendar.class, null) .convert(gc, Calendar.class); assertNotNull(calendar); assertEquals(1981, calendar.get(Calendar.YEAR)); assertEquals(5, calendar.get(Calendar.MONTH)); assertEquals(20, calendar.get(Calendar.DATE)); assertEquals(12, calendar.get(Calendar.HOUR_OF_DAY)); assertEquals(0, calendar.get(Calendar.MINUTE)); assertEquals(0, calendar.get(Calendar.SECOND)); }
public <T> T convert(Object source, Class<T> target) throws Exception { if (source instanceof GregorianCalendar) { return (T) DatatypeFactory.newInstance().newXMLGregorianCalendar( (GregorianCalendar) source); } return null; } };