List of usage examples for javax.xml.datatype XMLGregorianCalendar toGregorianCalendar
public abstract GregorianCalendar toGregorianCalendar();
From source file:Main.java
public static Timestamp xmlGregorianCalendarToTimestamp(XMLGregorianCalendar xgc) { if (xgc == null) { return null; }//w ww . j a v a2 s . c om GregorianCalendar gc = xgc.toGregorianCalendar(); return new Timestamp(gc.getTimeInMillis()); }
From source file:Main.java
/** * Converts an XMLGregorianCalendar to an instance of java.util.Date * * @param xgc Instance of XMLGregorianCalendar or a null reference * @return java.util.Date instance whose value is based upon the * value in the xgc parameter. If the xgc parameter is null then * this method will simply return null.//from w ww. java 2 s .co m */ public static Date calendarAsDate(XMLGregorianCalendar xgc) { if (xgc == null) { return null; } else { return xgc.toGregorianCalendar().getTime(); } }
From source file:Main.java
/** * Converts a <code>javax.xml.datatype.XMLGregorianCalendar</code> instance to a * <code>java.util.Date</code> instance. * * @param calendar the <code>javax.xml.datatype.XMLGregorianCalendar</code> instance to convert * * @return the converted <code>java.util.Date</code> instance *//*from w w w . j a v a 2 s . com*/ public static java.util.Date asDate(XMLGregorianCalendar calendar) { if (calendar == null) { return null; } else { return calendar.toGregorianCalendar().getTime(); } }
From source file:Main.java
/** * Parse an xs:dateTime value in "2009-05-21T14:52:18-07:00" format (with the timezone). * //w w w .j ava2 s .com * @param timestamp * The xs:dateTime * @return The converted date * @throws DatatypeConfigurationException * For errors. */ public static Date parseXmlDateTimeWithZone(String timestamp) throws DatatypeConfigurationException { DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); XMLGregorianCalendar xmlGregorianCalendar = datatypeFactory.newXMLGregorianCalendar(timestamp); GregorianCalendar gregorianCalendar = xmlGregorianCalendar.toGregorianCalendar(); return gregorianCalendar.getTime(); }
From source file:Main.java
public static Function<XMLGregorianCalendar, Date> toDate() { return new Function<XMLGregorianCalendar, Date>() { @Override/*from w w w . j av a 2s . co m*/ public Date apply(XMLGregorianCalendar xmlGregorianCalendar) { if (xmlGregorianCalendar == null) return null; return xmlGregorianCalendar.toGregorianCalendar().getTime(); } }; }
From source file:edu.utah.further.core.util.jaxb.JaxbConversionUtil.java
/** * Convert a JAXB calendar object to a {@link Date}. * * @param {@link XMLGregorianCalendar} date object * @return corresponding {@link Date object *///from w w w. j a v a2 s .c o m public static Date toDate(final XMLGregorianCalendar calendar) { return (calendar == null) ? null : calendar.toGregorianCalendar().getTime(); }
From source file:Main.java
/** * Convenience method to parse an XML Date Time into a Date. Only useful * when the XML Date Time is within the Date object time range. * * @param toParse/*from w ww .j a v a 2s. c o m*/ * the xml date time string to parse. * @return the parsed Date object. */ public static Date getDate(final String toParse) { XMLGregorianCalendar calendar = getXMLGregorianCalendar(toParse); if (calendar != null) { return new Date(calendar.toGregorianCalendar().getTimeInMillis()); } else { return null; } }
From source file:Main.java
/** * Convert the {@link XMLGregorianCalendar} into a {@link Date}. * /* w ww.j a v a2s. co m*/ * @param calendar * @return the converted date * @throws IllegalArgumentException if input is null */ public static Date convertXMLGregorianCalendarToDate(final XMLGregorianCalendar calendar) { if (null == calendar) { throw new IllegalArgumentException("cannot convert null date/time"); } return calendar.toGregorianCalendar().getTime(); }
From source file:com.aes.touresbalon.touresbalonoms.utilities.OmsUtil.java
public static Date xmlgGregorianCalendarToString(XMLGregorianCalendar fecha) { // DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); // Date fechaUtil = fecha.toGregorianCalendar().getTime(); // return formatter.format(fechaUtil); return fecha.toGregorianCalendar().getTime(); }
From source file:eu.prestoprime.p4gui.connection.AccessConnection.java
public static Date checkDataTypeAvailability(P4Service service, String id, String dataType) { String path = service.getURL() + "/access/dip/" + id + "/" + dataType; try {/*w w w . ja v a 2 s . c o m*/ P4HttpClient client = new P4HttpClient(service.getUserID()); HttpRequestBase request = new HttpGet(path); HttpResponse response = client.executeRequest(request); HttpEntity entity = response.getEntity(); if (entity != null) { String line; BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent())); if ((line = reader.readLine()) != null) { XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(line.trim()); return cal.toGregorianCalendar().getTime(); } } } catch (Exception e) { logger.error("Unable to parse the date..."); } return null; }