Java 8 DatatypeFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DatatypeFactory class.

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:newDuration, newXMLGregorianCalendar
        return et;
    } 
 
    public static ExpirationType toExpirationTypeContainingDuration(XMLGregorianCalendar date) {
        ExpirationType et = new ExpirationType();
        XMLGregorianCalendar now = factory.newXMLGregorianCalendar(new GregorianCalendar());
        XMLGregorianCalendar then = factory.newXMLGregorianCalendar(date.toGregorianCalendar());
        long durationMillis = then.toGregorianCalendar().getTimeInMillis()
                - now.toGregorianCalendar().getTimeInMillis();
        Duration duration = factory.newDuration(durationMillis);
        et.setValue(duration.toString());
        return et;
    } 
 
    public static boolean isPT0S(Duration duration) {
        return duration.toString().equals("PT0S");
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:newXMLGregorianCalendar
        } 
    } 
 
    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; 
    } 
5
CodeRank
This code example shows how to use the following methods:newDuration
      start = parseDate(expression.get(0));
      if (isDuration(expression.get(1))) {
        period = parsePeriod(expression.get(1));
      } else { 
        end = parseDate(expression.get(1));
        period = datatypeFactory.newDuration(end.getTimeInMillis() - start.getTimeInMillis());
      } 
    } 
    if (start == null && end == null) {
      start = clockReader.getCurrentCalendar();
    } 
 
  } 
 
  public Calendar getCalendarAfter() {
    return getCalendarAfter(clockReader.getCurrentCalendar());
  } 
   
  public Calendar getCalendarAfter(Calendar time) {
    if (isRepeat) {
5
CodeRank
This code example shows how to use the following methods:newXMLGregorianCalendar
            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;
		} 
 
		public void setScores(Map<String, String> scores) {
			this.scores = scores;
		} 
5
CodeRank
This code example shows how to use the following methods:newXMLGregorianCalendar
        try { 
            DatatypeFactory df = getDatatypeFactory();
            Date date = new Date(aNotification.getTimeStamp());
            GregorianCalendar gc = new GregorianCalendar();
            gc.setTime(date);
            jaxb.withDateTime(df.newXMLGregorianCalendar(gc));
 
            Object bean = wrap ? mObjectFactory.createNotificationEvent(jaxb) : jaxb;
 
            StringWriter sw = new StringWriter();
 
            // must create a new marshaller as its not thread safe 
            Marshaller marshaller = jaxbContext.createMarshaller();
            marshaller.marshal(bean, sw);
 
            return sw.toString();
        } catch (JAXBException e) {
            throw new NotificationFormatException(e);
        } catch (DatatypeConfigurationException e) {
            throw new NotificationFormatException(e);
5
CodeRank
This code example shows how to use the following methods:newXMLGregorianCalendar
This code example shows how to use the following methods:newXMLGregorianCalendar
This code example shows how to use the following methods:newXMLGregorianCalendar
This code example shows how to use the following methods:newXMLGregorianCalendar
            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;
		} 
 
		public void setScores(Map<String, String> scores) {
			this.scores = scores;
		} 
4
CodeRank

Related Java 8 DatatypeFactory Questions & Answers:

See Code Examples for Java 8 DatatypeFactory Methods: