Package javax.xml.datatype

Examples of javax.xml.datatype.DatatypeFactory.newDuration()


    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);
View Full Code Here


    }

    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);
View Full Code Here

        String out;
        String expected;
        String expected2;
       
        // test 1
        d = factory.newDuration("PT2H46M40S");
        df = DurationFormat.getInstance(new ULocale("en"));
        expected = "2 hours, 46 minutes, and 40 seconds";
        out = df.format(d);
        if(out.equals(expected)) {
            logln("out=expected: " + expected + " from " + d);
View Full Code Here

        } else {
            errln("FAIL: got " + out + " wanted " + expected + " from " + d);
        }
       
        // test 2
        d = factory.newDuration(10000);
        df = DurationFormat.getInstance(new ULocale("en"));
        expected = "10 seconds";
        out = df.format(d);
        if(out.equals(expected)) {
            logln("out=expected: " + expected + " from " + d);
View Full Code Here

            logln("out=expected: " + expected + " from " + d);
        } else {
            errln("FAIL: got " + out + " wanted " + expected + " from " + d);
        }
        // test 3
        d = factory.newDuration("P0DT0H0M10.0S");
        df = DurationFormat.getInstance(new ULocale("en"));
        expected = "10 seconds";
        out = df.format(d);
        if(out.equals(expected)) {
            logln("out=expected: " + expected + " from " + d);
View Full Code Here

            logln("out=expected: " + expected + " from " + d);
        } else {
            errln("FAIL: got " + out + " wanted " + expected + " from " + d);
        }
        // test 4
        d = factory.newDuration(86400000);
        df = DurationFormat.getInstance(new ULocale("en"));
        expected = "1 day, 0 hours, 0 minutes, and 0 seconds";
        expected2 = "1 day and 0 seconds"; // This is the expected result for Windows with IBM JRE6
        out = df.format(d);
        if(out.equals(expected)) {
View Full Code Here

            String to = cases[n+2];
           
            ULocale locale = new ULocale(loc);
            Duration d;
            if(from.startsWith("#")) {
                d = factory.newDuration(Long.parseLong(from.substring(1)));
            } else {
                d = factory.newDuration(from);
            }
           
            DurationFormat df = DurationFormat.getInstance(locale);
View Full Code Here

            ULocale locale = new ULocale(loc);
            Duration d;
            if(from.startsWith("#")) {
                d = factory.newDuration(Long.parseLong(from.substring(1)));
            } else {
                d = factory.newDuration(from);
            }
           
            DurationFormat df = DurationFormat.getInstance(locale);
            String output = df.format(d);
           
View Full Code Here

          "parameter can not be null for Duration");
    }

    try {
      DatatypeFactory aFactory = DatatypeFactory.newInstance();
      return new Duration(aFactory.newDuration(stringValue));
    } catch (DatatypeConfigurationException ex1) {
      Logger.getLogger(Duration.class.getName()).log(Level.SEVERE,
          "DatatypeFactory can not be instanced", ex1);
      return null;
    } catch (IllegalArgumentException ex2) {
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.