Package javax.xml.datatype

Examples of javax.xml.datatype.DatatypeFactory


            Assert.assertEquals(xgcals[i], actual[i]);
        }
    }

    private void performTestNewDuration(StandardTypesServiceClient serviceClient) throws DatatypeConfigurationException {
        DatatypeFactory df = DatatypeFactory.newInstance();
        Duration[] da = new Duration[3];
        da[0] = df.newDuration(1000000000000L);
        da[1] = df.newDurationDayTime(1000000000000L);
        da[2] = df.newDurationYearMonth(true, 1, 3);

        for (int i = 0; i < da.length; ++i) {
            Assert.assertEquals(da[i].negate(), serviceClient.getNewDurationForward(da[i]));
        }
    }
View Full Code Here


        }
    }

    private void performTestNewDurationArray(StandardTypesServiceClient serviceClient)
        throws DatatypeConfigurationException {
        DatatypeFactory df = DatatypeFactory.newInstance();
        Duration[] da = new Duration[3];
        da[0] = df.newDuration(1000000000000L);
        da[1] = df.newDurationDayTime(1000000000000L);
        da[2] = df.newDurationYearMonth(true, 1, 3);

        Duration[] actual = serviceClient.getNewDurationArrayForward(da);
        Assert.assertEquals(da.length, actual.length);
        for (int i = 0; i < da.length; ++i) {
            Assert.assertEquals(da[i].negate(), actual[i]);
View Full Code Here

      if (userExpiration.getTimeInMillis() < expirationDate.getTimeInMillis())
        expirationDate.setTimeInMillis(userExpiration.getTimeInMillis());
    }

    try {
      DatatypeFactory df = DatatypeFactory.newInstance();
      apiSubscription.setExpiresAfter(df.newXMLGregorianCalendar(expirationDate));
    }
    catch(DatatypeConfigurationException ce) {
      throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
    }
   
View Full Code Here

    public static List<XMLGregorianCalendar> convertCalendar(List<GregorianCalendar> calendar) {
        if (calendar == null) {
            return null;
        }

        DatatypeFactory df;
        try {
            df = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
        }

        List<XMLGregorianCalendar> result = new ArrayList<XMLGregorianCalendar>();
        for (GregorianCalendar cal : calendar) {
            result.add(df.newXMLGregorianCalendar(cal));
        }

        return result;
    }
View Full Code Here

    public static XMLGregorianCalendar convertCalendar(GregorianCalendar calendar) {
        if (calendar == null) {
            return null;
        }

        DatatypeFactory df;
        try {
            df = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new CmisRuntimeException("Convert exception: " + e.getMessage(), e);
        }

        return df.newXMLGregorianCalendar(calendar);
    }
View Full Code Here

   private static XMLGregorianCalendar getXMLGregorianCalendar(GregorianCalendar gregorianCalendar)
   {
      try
      {
         DatatypeFactory dtf = DatatypeFactory.newInstance();
         return dtf.newXMLGregorianCalendar(gregorianCalendar);
      }
      catch (DatatypeConfigurationException e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

    }

    private static XMLGregorianCalendar getCalendar() {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(1234567);
        DatatypeFactory datatypeFactory;
        try {
            datatypeFactory = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new RuntimeException(e);
        }
        XMLGregorianCalendar xmlGregCal = datatypeFactory.newXMLGregorianCalendar(calendar);
        return xmlGregCal;
    }
View Full Code Here

      }
      // update editing-duration info.
      long editingDuration = calendar.getTimeInMillis() - documentOpeningTime;
      editingDuration = (editingDuration < 1) ? 1 : editingDuration;
      try {
        DatatypeFactory aFactory = DatatypeFactory.newInstance();
        metaData.setEditingDuration(new Duration(aFactory.newDurationDayTime(editingDuration)));
      } catch (DatatypeConfigurationException e) {
        Logger.getLogger(Document.class.getName()).log(Level.SEVERE,
            "editing duration update fail as DatatypeFactory can not be instanced", e);
      }
    }
View Full Code Here

     * @param calendar Object to be converted
     * @return XMLGregorianCalendar
     */
    private XMLGregorianCalendar calendarToXMLGregorianCalendar(Calendar calendar) throws DatatypeConfigurationException {

        DatatypeFactory dtf = DatatypeFactory.newInstance();
        XMLGregorianCalendar xgc = dtf.newXMLGregorianCalendar();
        xgc.setYear(calendar.get(Calendar.YEAR));
        xgc.setMonth(calendar.get(Calendar.MONTH) + 1);
        xgc.setDay(calendar.get(Calendar.DAY_OF_MONTH));
        xgc.setHour(calendar.get(Calendar.HOUR_OF_DAY));
        xgc.setMinute(calendar.get(Calendar.MINUTE));
View Full Code Here

            /*
             * Get the DatatypeFactory first because if not available, then we don't need to parse
             * the calendar fields. This has the side effect of not validating the calendar fields
             * syntax (which should be integer values), but maybe this is what the user wants.
             */
            final DatatypeFactory factory = XmlUtilities.getDatatypeFactory();
            final org.apache.sis.internal.geoapi.temporal.PeriodDuration metadata =
                    (org.apache.sis.internal.geoapi.temporal.PeriodDuration) this.metadata;
            InternationalString value;
            BigInteger years = null;
            if ((value = metadata.getYears()) != null) {
                years = new BigInteger(value.toString());
            }
            BigInteger months = null;
            if ((value = metadata.getMonths()) != null) {
                months = new BigInteger(value.toString());
            }
            BigInteger days = null;
            if ((value = metadata.getDays()) != null) {
                days = new BigInteger(value.toString());
            }
            BigInteger hours = null;
            if ((value = metadata.getHours()) != null) {
                hours = new BigInteger(value.toString());
            }
            BigInteger minutes = null;
            if ((value = metadata.getMinutes()) != null) {
                minutes = new BigInteger(value.toString());
            }
            BigDecimal seconds = null;
            if ((value = metadata.getSeconds()) != null) {
                seconds = new BigDecimal(value.toString());
            }
            return factory.newDuration(true, years, months, days, hours, minutes, seconds);
        } catch (DatatypeConfigurationException e) {
            warningOccured("getElement", e);
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of javax.xml.datatype.DatatypeFactory

Copyright © 2018 www.massapicom. 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.