DatatypeFactory newXMLGregorianCalendar - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DatatypeFactory newXMLGregorianCalendar method.

This code example shows how to use the following methods:setTime
	 
	 
	private static XMLGregorianCalendar toXMLGregorianCalendar(
            Date source, DatatypeFactory factory) {
         
        GregorianCalendar c = new GregorianCalendar();
        c.setTime(source);
         
        return factory.newXMLGregorianCalendar(c);
         
    } 
	 
	public static class MapOfScores { 
		 
		private Map<String, String> scores;
 
		public Map<String, String> getScores() {
			return scores;
		} 
 
7
CodeRank
This code example shows how to use the following methods:get, setTime
            return new Date();
        } 
    } 
 
    public static synchronized String fromDate(Date date) {
        calendar.setTime(date);
        XMLGregorianCalendar xgc = XML_DATE.newXMLGregorianCalendar(calendar);
        if (calendar.get(Calendar.MILLISECOND) == 0) xgc.setFractionalSecond(null);
        return xgc.toXMLFormat();
    } 
 
    private static boolean checkLayout(String text, String pattern) {
        if (text.length() != pattern.length()) return false;
        for (int i=0; i<pattern.length(); i++) {
            char pc = pattern.charAt(i);
            char tc = text.charAt(i);
            if(pc == 'x' && tc >= '0' && tc <= '9') continue;
            else if(pc == 'x' || pc != tc) return false;
        } 
        return true; 
7
CodeRank
This code example shows how to use the following methods:setTime
        return null; 
    } 
 
    static XMLGregorianCalendar sqlDateToXMLCal(java.sql.Date sqlDate) {
        java.util.Date jDate = new java.util.Date(sqlDate.getTime());
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(jDate);
        return df.newXMLGregorianCalendar(calendar);
    } 
 
    static void checkEmployeeRecordType(EmployeeRecordType ert)
            throws DataProcessingFault { 
        checkNotEmpty(ert.getFirstName(), "First Name");
        checkNotEmpty(ert.getLastName(), "Last Name");
        checkNotEmpty(ert.getDepartmentId(), "Department Id");
        checkNotEmpty(ert.getHiredate(), "Hiredate");
    } 
 
    static void checkEmployeeIDExists(Integer employeeId)
            throws DataProcessingFault { 
7
CodeRank
This code example shows how to use the following methods:setTime
    if (amfObject == null) {
      return null; 
    } 
 
    try { 
      GregorianCalendar gregorianCal = new GregorianCalendar();
      gregorianCal.setTime(amfObject);
 
      DatatypeFactory factory = DatatypeFactory.newInstance();
      return factory.newXMLGregorianCalendar(gregorianCal);
    } 
    catch (DatatypeConfigurationException e) {
      throw new AMFMappingException("Internal Error mapping from AMF to an instance of XMLGregorianCalendar: ", e);
    } 
  } 
 
  public Class<? extends XMLGregorianCalendar> getJaxbClass() {
    return XMLGregorianCalendar.class;
  } 
 
6
CodeRank
This code example shows how to use the following methods:newXMLGregorianCalendar
	public JAXBElement<URI> standardClassURI() {
		return new JAXBElement<URI>(NAME, URI.class, URI.create("http://springframework.org"));
	} 
 
	public JAXBElement<XMLGregorianCalendar> standardClassXMLGregorianCalendar() throws DatatypeConfigurationException {
		XMLGregorianCalendar calendar =
				factory.newXMLGregorianCalendar((GregorianCalendar) Calendar.getInstance());
		return new JAXBElement<XMLGregorianCalendar>(NAME, XMLGregorianCalendar.class, calendar);
	} 
 
	public JAXBElement<Duration> standardClassDuration() {
		Duration duration = factory.newDuration(42000);
		return new JAXBElement<Duration>(NAME, Duration.class, duration);
	} 
 
	public JAXBElement<Image> standardClassImage() throws IOException {
		Image image = ImageIO.read(getClass().getResourceAsStream("spring-ws.png"));
		return new JAXBElement<Image>(NAME, Image.class, image);
	} 
 
6
CodeRank
This code example shows how to use the following methods:setTimeInMillis
 
 
public class DTOFactory { 
	 
    public XMLGregorianCalendar getXMLGregorianCalendar(long timeInMilliSec) {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTimeInMillis(timeInMilliSec);
 
        return getXMLGregorianCalendar(cal);
    } 
 
    public XMLGregorianCalendar getXMLGregorianCalendar(GregorianCalendar cal) {
        DatatypeFactory dataTypeFactory;
        XMLGregorianCalendar xmlCalendar = null;
 
        try { 
            dataTypeFactory = DatatypeFactory.newInstance();
            xmlCalendar = dataTypeFactory.newXMLGregorianCalendar(cal);
        } catch (DatatypeConfigurationException e) {
            e.printStackTrace();

6
CodeRank
This code example shows how to use the following methods:setTimeInMillis
public class TypeConvertor { 
	public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(Date date) throws DispositionReportFaultMessage {
		XMLGregorianCalendar result = null;
		try {  
			if (date!=null) {
				GregorianCalendar gc = new GregorianCalendar();
				gc.setTimeInMillis(date.getTime());
				 
				DatatypeFactory df = DatatypeFactory.newInstance();
				result = df.newXMLGregorianCalendar(gc);
			} 
		} 
		catch(DatatypeConfigurationException ce) { 
			throw new FatalErrorException(new ErrorMessage("errors.Unspecified")); 
		} 
		 
		return result;
	} 
	 
	public static Duration convertStringToDuration(String duration) throws DispositionReportFaultMessage {
6
CodeRank
This code example shows how to use the following methods:add
	 * @return Current date + minutes + seconds 
	 */ 
	public static XMLGregorianCalendar generateXMLCalendar(final int rollMin,
			final int rollSeconds) {
		GregorianCalendar calendar;
		calendar = new GregorianCalendar(getDefaultTimeZone());
		if (rollSeconds != 0) {
			calendar.add(Calendar.SECOND, rollSeconds);
		} 
		if (rollMin != 0) {
			calendar.add(Calendar.MINUTE, rollMin);
		} 
 
		try { 
			DatatypeFactory factory = DatatypeFactory.newInstance();
			return factory.newXMLGregorianCalendar(calendar);
		} catch (DatatypeConfigurationException e) {
			return null; 
		} 
	} 
 
6
CodeRank
This code example shows how to use the following methods:setTimeInMillis
   */ 
  public static XMLGregorianCalendar asXMLGregorianCalendar( java.util.Date date ) {
    if ( date == null ) {
      return null; 
    } else { 
      GregorianCalendar gc = new GregorianCalendar();
      gc.setTimeInMillis( date.getTime() );
      return df.newXMLGregorianCalendar( gc );
    } 
  } 
 
  /** 
   * 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. 
   */ 
  public static java.util.Date asDate( XMLGregorianCalendar xgc ) {
6
CodeRank
This code example shows how to use the following methods:setTimeInMillis
     */ 
    public static XMLGregorianCalendar asXMLGregorianCalendar(java.util.Date date) {
        if (date == null) {
            return null; 
        } else { 
            GregorianCalendar gc = new GregorianCalendar();
            gc.setTimeInMillis(date.getTime());
            return df.newXMLGregorianCalendar(gc);
        } 
    } 
 
    /** 
     * 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. 
     */ 
    public static java.util.Date asDate(XMLGregorianCalendar xgc) {
6
CodeRank

Related DatatypeFactory newXMLGregorianCalendar Questions & Answers:

newXMLGregorianCalendar Method Overview
Create a new XMLGregorianCalendar by parsing the String as a lexical representation.
See Code Examples for other Java 8 DatatypeFactory Methods: