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


    throws IllegalArgumentException
  {
    XMLGregorianCalendar xmlCal =
      getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDate);

    return xmlCal.toGregorianCalendar();
  }

  public Calendar parseDateTime(String lexicalXSDDateTime)
    throws IllegalArgumentException
  {
View Full Code Here

    throws IllegalArgumentException
  {
    XMLGregorianCalendar xmlCal =
      getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDateTime);

    return xmlCal.toGregorianCalendar();
  }

  public BigDecimal parseDecimal(String lexicalXSDDecimal)
  {
    return new BigDecimal(lexicalXSDDecimal);
View Full Code Here

    throws IllegalArgumentException
  {
    XMLGregorianCalendar xmlCal =
      getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDTime);

    return xmlCal.toGregorianCalendar();
  }

  public long parseUnsignedInt(String lexicalXSDUnsignedInt)
  {
    long x = parseLong(lexicalXSDUnsignedInt);
View Full Code Here

    assertEquals(cal.get(Calendar.MONTH) + 1, xmlCal.getMonth());
    assertEquals(cal.get(Calendar.DAY_OF_MONTH), xmlCal.getDay());
    assertEquals(cal.get(Calendar.HOUR_OF_DAY), xmlCal.getHour());
    assertEquals(cal.get(Calendar.MINUTE), xmlCal.getMinute());
    assertEquals(cal.get(Calendar.SECOND), xmlCal.getSecond());
    assertEquals(cal.getTime(), xmlCal.toGregorianCalendar().getTime());
  }
}
View Full Code Here

         if (askedLifetime != null)
         {
            final XMLGregorianCalendar askedLifetimeCurrentTime = askedLifetime.getCurrentTime();
            long currentTime = toLongDate(askedLifetimeCurrentTime);
            long terminationTime = toLongDate(askedLifetime.getTerminationTime());
            long refreshDuration = askedLifetime.getRefreshDuration().getTimeInMillis(askedLifetimeCurrentTime.toGregorianCalendar());
            exportContext = exportManager.createExportContext(exportByValueRequired, currentTime, terminationTime, refreshDuration);
         }
         else
         {
            exportContext = exportManager.createExportContext(exportByValueRequired, -1, -1, -1);
View Full Code Here

             }else{
                 throw XMLConversionException.incorrectTimestampDateTimeFormat(sourceString);
             }
        }

        GregorianCalendar cal = xmlGregorianCalender.toGregorianCalendar();
        cal.setTimeZone(getTimeZone());

        QName  calendarQName = xmlGregorianCalender.getXMLSchemaType();
        if(!calendarQName.equals(schemaType)){
            if (XMLConstants.DATE_QNAME.equals(schemaType)){
View Full Code Here

        }
        // An XMLGregorianCalendar will be used to parse the date string
        XMLGregorianCalendar xgc = getXMLConversionManager().convertStringToXMLGregorianCalendar(dateString);
        Calendar cal;
        if (xgc.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
            cal = xgc.toGregorianCalendar(getXMLConversionManager().getTimeZone(), locale, null);
            cal.clear(Calendar.ZONE_OFFSET);
        } else {
            cal = xgc.toGregorianCalendar(xgc.getTimeZone(xgc.getTimezone()), locale, null);
        }
        return cal;
View Full Code Here

        Calendar cal;
        if (xgc.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
            cal = xgc.toGregorianCalendar(getXMLConversionManager().getTimeZone(), locale, null);
            cal.clear(Calendar.ZONE_OFFSET);
        } else {
            cal = xgc.toGregorianCalendar(xgc.getTimeZone(xgc.getTimezone()), locale, null);
        }
        return cal;
    }

    /**
 
View Full Code Here

    XMLGregorianCalendar cal2 = XMLGregorianCalendarImpl.parse(str);
    Duration dur;
    try {
      dur = DatatypeFactory.newInstance().newDuration(
          cal1.toGregorianCalendar().getTimeInMillis()
              - cal2.toGregorianCalendar().getTimeInMillis());
    } catch (DatatypeConfigurationException e) {
      return null;
    }
    return BuiltinHelper.createXSLiteral(
        dur.toString().substring(0, dur.toString().indexOf("M") + 1),
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.