Package javax.xml.datatype

Examples of javax.xml.datatype.XMLGregorianCalendar.toGregorianCalendar()


  @Test
  public void testXmlGregorianCalendar() {
    XMLGregorianCalendar xmlCalendar = mock(XMLGregorianCalendar.class);
    GregorianCalendar expected = new GregorianCalendar();
    when(xmlCalendar.toGregorianCalendar()).thenReturn(expected);
    Date date = new Date(expected.getTimeInMillis());

    assertEquals(date, converter.convert(Date.class, xmlCalendar));
  }
View Full Code Here


           
            XMLGregorianCalendar gc = factory.createConverter(Calendar.class, XMLGregorianCalendar.class, null)
                .convert( calendar, XMLGregorianCalendar.class );
            assertNotNull(gc);
           
            Calendar actual = gc.toGregorianCalendar();
            assertEquals( calendar.get( Calendar.YEAR ), actual.get( Calendar.YEAR) );
            assertEquals( calendar.get( Calendar.MONTH ), actual.get( Calendar.MONTH) );
            assertEquals( calendar.get( Calendar.DATE ), actual.get( Calendar.DATE) );
            assertEquals( calendar.get( Calendar.HOUR_OF_DAY ), actual.get( Calendar.HOUR_OF_DAY) );
            assertEquals( calendar.get( Calendar.MINUTE ), actual.get( Calendar.MINUTE) );
View Full Code Here

            XMLGregorianCalendar gc = factory.createConverter( Date.class, XMLGregorianCalendar.class, null )
                    .convert( date, XMLGregorianCalendar.class );
           
            assertNotNull( gc );
           
            assertEquals( date, gc.toGregorianCalendar().getTime() );
  }
   
    public void testTimeZoneToString() throws Exception {
        Converter converter = factory.createConverter(TimeZone.class, String.class, null);
        assertNotNull(converter);
View Full Code Here

        if (EjbTagNames.TIMER_START.equals(element.getQName())) {
            try {
                DatatypeFactory dFactory = DatatypeFactory.newInstance();

                XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(value);
                GregorianCalendar cal = xmlGreg.toGregorianCalendar();
                descriptor.setStart(cal.getTime());
            } catch (Exception e) {
                DOLUtils.getDefaultLogger().warning(e.getMessage());
            }
View Full Code Here

        } else if(EjbTagNames.TIMER_END.equals(element.getQName())) {
            try {
                DatatypeFactory dFactory = DatatypeFactory.newInstance();

                XMLGregorianCalendar xmlGreg = dFactory.newXMLGregorianCalendar(value);
                GregorianCalendar cal = xmlGreg.toGregorianCalendar();
                descriptor.setEnd(cal.getTime());
            } catch (Exception e) {
                DOLUtils.getDefaultLogger().warning(e.getMessage());
            }
View Full Code Here

        if (XMLGregorianCalendar.class.isAssignableFrom(source)) {
            if (Calendar.class.isAssignableFrom(target)) {
                return new Converter() {
                    public <T> T convert(Object source, Class<T> target) throws Exception {
                        XMLGregorianCalendar calendar = (XMLGregorianCalendar) source;
                        return (T) calendar.toGregorianCalendar();
                    }
                };
            }
            if (Date.class.isAssignableFrom(target)) {
                return new Converter() {
View Full Code Here

      return true; // NOPMD by wim on 9/20/10 2:28 PM
    }
    if (this.date!=null) {
      try{
        final  XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar();
        if ( !this.date.equals( date.toGregorianCalendar().getTime() ) ) {
          return true; // NOPMD by wim on 9/20/10 2:28 PM
        }
      } catch (DatatypeConfigurationException e) {
        return false; // fatal // NOPMD by wim on 9/20/10 2:28 PM
      }
View Full Code Here

      return this.bool; // NOPMD by wim on 9/20/10 2:28 PM
    }
    if (this.date!=null) {
      try{
        final  XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar();
        if ( !this.date.equals( date.toGregorianCalendar().getTime() ) ) {
          return date; // NOPMD by wim on 9/20/10 2:28 PM
        }
      } catch (DatatypeConfigurationException e) {
        return null; // fatal // NOPMD by wim on 9/20/10 2:28 PM
      }
View Full Code Here

             }
        }
        if(xmlGregorianCalender == null) {
            return null;
        }
        GregorianCalendar cal = xmlGregorianCalender.toGregorianCalendar();
        if(xmlGregorianCalender.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
            cal.setTimeZone(getTimeZone());
        }
        QName  calendarQName = xmlGregorianCalender.getXMLSchemaType();
        if(!calendarQName.equals(schemaType)){
View Full Code Here

      XMLGregorianCalendar date = n.getDate();
      final String dt;
      if (date == null) {
        dt = "Ongoing";
      } else {
        dt = new SimpleDateFormat("MMMM dd, yyyy", Locale.ENGLISH).format(date.toGregorianCalendar().getTime());
      }
      fw.write("<h2>"+dt+"</h2>" + html(n.getValue()));
    }
    closeHTML(fw);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.