Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.GDurationBuilder


    d = ( XmlDuration )sType.getFacet( SchemaType.FACET_MAX_EXCLUSIVE );
    GDuration maxExclusive = null;
    if( d != null )
      maxExclusive = d.getGDurationValue();

    GDurationBuilder gdurb = new GDurationBuilder();
    @SuppressWarnings( "unused" )
    BigInteger min, max;

    gdurb.setSecond( pick( 800000 ) );
    gdurb.setMonth( pick( 20 ) );

    // Years
    // Months
    // Days
    // Hours
    // Minutes
    // Seconds
    // Fractions
    if( minInclusive != null )
    {
      if( gdurb.getYear() < minInclusive.getYear() )
        gdurb.setYear( minInclusive.getYear() );
      if( gdurb.getMonth() < minInclusive.getMonth() )
        gdurb.setMonth( minInclusive.getMonth() );
      if( gdurb.getDay() < minInclusive.getDay() )
        gdurb.setDay( minInclusive.getDay() );
      if( gdurb.getHour() < minInclusive.getHour() )
        gdurb.setHour( minInclusive.getHour() );
      if( gdurb.getMinute() < minInclusive.getMinute() )
        gdurb.setMinute( minInclusive.getMinute() );
      if( gdurb.getSecond() < minInclusive.getSecond() )
        gdurb.setSecond( minInclusive.getSecond() );
      if( gdurb.getFraction().compareTo( minInclusive.getFraction() ) < 0 )
        gdurb.setFraction( minInclusive.getFraction() );
    }

    if( maxInclusive != null )
    {
      if( gdurb.getYear() > maxInclusive.getYear() )
        gdurb.setYear( maxInclusive.getYear() );
      if( gdurb.getMonth() > maxInclusive.getMonth() )
        gdurb.setMonth( maxInclusive.getMonth() );
      if( gdurb.getDay() > maxInclusive.getDay() )
        gdurb.setDay( maxInclusive.getDay() );
      if( gdurb.getHour() > maxInclusive.getHour() )
        gdurb.setHour( maxInclusive.getHour() );
      if( gdurb.getMinute() > maxInclusive.getMinute() )
        gdurb.setMinute( maxInclusive.getMinute() );
      if( gdurb.getSecond() > maxInclusive.getSecond() )
        gdurb.setSecond( maxInclusive.getSecond() );
      if( gdurb.getFraction().compareTo( maxInclusive.getFraction() ) > 0 )
        gdurb.setFraction( maxInclusive.getFraction() );
    }

    if( minExclusive != null )
    {
      if( gdurb.getYear() <= minExclusive.getYear() )
        gdurb.setYear( minExclusive.getYear() + 1 );
      if( gdurb.getMonth() <= minExclusive.getMonth() )
        gdurb.setMonth( minExclusive.getMonth() + 1 );
      if( gdurb.getDay() <= minExclusive.getDay() )
        gdurb.setDay( minExclusive.getDay() + 1 );
      if( gdurb.getHour() <= minExclusive.getHour() )
        gdurb.setHour( minExclusive.getHour() + 1 );
      if( gdurb.getMinute() <= minExclusive.getMinute() )
        gdurb.setMinute( minExclusive.getMinute() + 1 );
      if( gdurb.getSecond() <= minExclusive.getSecond() )
        gdurb.setSecond( minExclusive.getSecond() + 1 );
      if( gdurb.getFraction().compareTo( minExclusive.getFraction() ) <= 0 )
        gdurb.setFraction( minExclusive.getFraction().add( new BigDecimal( 0.001 ) ) );
    }

    if( maxExclusive != null )
    {
      if( gdurb.getYear() > maxExclusive.getYear() )
        gdurb.setYear( maxExclusive.getYear() );
      if( gdurb.getMonth() > maxExclusive.getMonth() )
        gdurb.setMonth( maxExclusive.getMonth() );
      if( gdurb.getDay() > maxExclusive.getDay() )
        gdurb.setDay( maxExclusive.getDay() );
      if( gdurb.getHour() > maxExclusive.getHour() )
        gdurb.setHour( maxExclusive.getHour() );
      if( gdurb.getMinute() > maxExclusive.getMinute() )
        gdurb.setMinute( maxExclusive.getMinute() );
      if( gdurb.getSecond() > maxExclusive.getSecond() )
        gdurb.setSecond( maxExclusive.getSecond() );
      if( gdurb.getFraction().compareTo( maxExclusive.getFraction() ) > 0 )
        gdurb.setFraction( maxExclusive.getFraction() );
    }

    gdurb.normalize();
    return gdurb.toString();
  }
View Full Code Here


                    Assert.assertTrue("Problem with " + str2 + ": " + e.getMessage(), false);
                }

                // subtracting two ways works
                GDuration diff = gd.subtract(gd2);
                GDurationBuilder gdb = new GDurationBuilder(gd2);
                gdb.setSign(-gdb.getSign());
                gdb.addGDuration(gd);
                GDuration sum2 = gdb.toGDuration();
                Assert.assertEquals(0, diff.compareToGDuration(sum2));
                gdb.normalize();
                GDurationBuilder gdb1 = new GDurationBuilder(diff);
                gdb1.normalize();
                Assert.assertEquals("Problem: " + gd + " and " + gd2, gdb.toString(), gdb1.toString());


                // comparing is reversible
                int comp1 = gd.compareToGDuration(gd2);
                int comp2 = gd2.compareToGDuration(gd);
View Full Code Here

            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.SERVICETIME);
            ServiceTimeDocument serviceTimeDocument = ServiceTimeDocument.Factory.newInstance();
            DurationMetric serviceTimeMetric = serviceTimeDocument.addNewServiceTime();
            GDurationBuilder builder = new GDurationBuilder(+1, 1, 2, 3, 4, 5, 6, new BigDecimal("0.789"));
            serviceTimeMetric.setGDurationValue(builder.toGDuration());
            serviceTimeMetric.setDuration(builder.toGDuration());
            resourceProperty.add(serviceTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.MAXRESPONSETIME);
            MaxResponseTimeDocument maxResponseTimeDocument = MaxResponseTimeDocument.Factory.newInstance();
            DurationMetric maxRespDurationMetric = maxResponseTimeDocument.addNewMaxResponseTime();
            maxRespDurationMetric.setGDurationValue(builder.toGDuration());
            maxRespDurationMetric.setDuration(builder.toGDuration());
            resourceProperty.add(maxResponseTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.LASTRESPONSETIME);
            LastResponseTimeDocument lastResponseTimeDocument = LastResponseTimeDocument.Factory.newInstance();
            DurationMetric lastRespDurationMetric = lastResponseTimeDocument.addNewLastResponseTime();
            lastRespDurationMetric.setGDurationValue(builder.toGDuration());
            lastRespDurationMetric.setDuration(builder.toGDuration());
            resourceProperty.add(lastResponseTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);
        }
        catch (Exception e)
        {
View Full Code Here

        d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
        GDuration maxExclusive = null;
        if (d != null)
            maxExclusive = d.getGDurationValue();

        GDurationBuilder gdurb = new GDurationBuilder();
        BigInteger min, max;

        gdurb.setSecond(pick(800000));
        gdurb.setMonth(pick(20));

        // Years
        // Months
        // Days
        // Hours
        // Minutes
        // Seconds
        // Fractions
        if (minInclusive != null)
        {
            if (gdurb.getYear() < minInclusive.getYear())
                gdurb.setYear(minInclusive.getYear());
            if (gdurb.getMonth() < minInclusive.getMonth())
                gdurb.setMonth(minInclusive.getMonth());
            if (gdurb.getDay() < minInclusive.getDay())
                gdurb.setDay(minInclusive.getDay());
            if (gdurb.getHour() < minInclusive.getHour())
                gdurb.setHour(minInclusive.getHour());
            if (gdurb.getMinute() < minInclusive.getMinute())
                gdurb.setMinute(minInclusive.getMinute());
            if (gdurb.getSecond() < minInclusive.getSecond())
                gdurb.setSecond(minInclusive.getSecond());
            if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0)
                gdurb.setFraction(minInclusive.getFraction());
        }

        if (maxInclusive != null)
        {
            if (gdurb.getYear() > maxInclusive.getYear())
                gdurb.setYear(maxInclusive.getYear());
            if (gdurb.getMonth() > maxInclusive.getMonth())
                gdurb.setMonth(maxInclusive.getMonth());
            if (gdurb.getDay() > maxInclusive.getDay())
                gdurb.setDay(maxInclusive.getDay());
            if (gdurb.getHour() > maxInclusive.getHour())
                gdurb.setHour(maxInclusive.getHour());
            if (gdurb.getMinute() > maxInclusive.getMinute())
                gdurb.setMinute(maxInclusive.getMinute());
            if (gdurb.getSecond() > maxInclusive.getSecond())
                gdurb.setSecond(maxInclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0)
                gdurb.setFraction(maxInclusive.getFraction());
        }

        if (minExclusive != null)
        {
            if (gdurb.getYear() <= minExclusive.getYear())
                gdurb.setYear(minExclusive.getYear()+1);
            if (gdurb.getMonth() <= minExclusive.getMonth())
                gdurb.setMonth(minExclusive.getMonth()+1);
            if (gdurb.getDay() <= minExclusive.getDay())
                gdurb.setDay(minExclusive.getDay()+1);
            if (gdurb.getHour() <= minExclusive.getHour())
                gdurb.setHour(minExclusive.getHour()+1);
            if (gdurb.getMinute() <= minExclusive.getMinute())
                gdurb.setMinute(minExclusive.getMinute()+1);
            if (gdurb.getSecond() <= minExclusive.getSecond())
                gdurb.setSecond(minExclusive.getSecond()+1);
            if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0)
                gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001)));
        }

        if (maxExclusive != null)
        {
            if (gdurb.getYear() > maxExclusive.getYear())
                gdurb.setYear(maxExclusive.getYear());
            if (gdurb.getMonth() > maxExclusive.getMonth())
                gdurb.setMonth(maxExclusive.getMonth());
            if (gdurb.getDay() > maxExclusive.getDay())
                gdurb.setDay(maxExclusive.getDay());
            if (gdurb.getHour() > maxExclusive.getHour())
                gdurb.setHour(maxExclusive.getHour());
            if (gdurb.getMinute() > maxExclusive.getMinute())
                gdurb.setMinute(maxExclusive.getMinute());
            if (gdurb.getSecond() > maxExclusive.getSecond())
                gdurb.setSecond(maxExclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0)
                gdurb.setFraction(maxExclusive.getFraction());
        }

        gdurb.normalize();
        return gdurb.toString();
    }
View Full Code Here

            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.SERVICETIME);
            ServiceTimeDocument serviceTimeDocument = ServiceTimeDocument.Factory.newInstance();
            DurationMetric serviceTimeMetric = serviceTimeDocument.addNewServiceTime();
            GDurationBuilder builder = new GDurationBuilder(+1, 1, 2, 3, 4, 5, 6, new BigDecimal("0.789"));
            serviceTimeMetric.setGDurationValue(builder.toGDuration());
            serviceTimeMetric.setDuration(builder.toGDuration());
            resourceProperty.add(serviceTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.MAXRESPONSETIME);
            MaxResponseTimeDocument maxResponseTimeDocument = MaxResponseTimeDocument.Factory.newInstance();
            DurationMetric maxRespDurationMetric = maxResponseTimeDocument.addNewMaxResponseTime();
            maxRespDurationMetric.setGDurationValue(builder.toGDuration());
            maxRespDurationMetric.setDuration(builder.toGDuration());
            resourceProperty.add(maxResponseTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);

            resourceProperty = resourcePropertySet.get(WeatherstationPropertyQNames.LASTRESPONSETIME);
            LastResponseTimeDocument lastResponseTimeDocument = LastResponseTimeDocument.Factory.newInstance();
            DurationMetric lastRespDurationMetric = lastResponseTimeDocument.addNewLastResponseTime();
            lastRespDurationMetric.setGDurationValue(builder.toGDuration());
            lastRespDurationMetric.setDuration(builder.toGDuration());
            resourceProperty.add(lastResponseTimeDocument);
            resourceProperty.addChangeListener(mowsMetricsCapability);
        }
        catch (Exception e)
        {
View Full Code Here

        d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
        GDuration maxExclusive = null;
        if (d != null)
            maxExclusive = d.getGDurationValue();

        GDurationBuilder gdurb = new GDurationBuilder();
        BigInteger min, max;

        gdurb.setSecond(pick(800000));
        gdurb.setMonth(pick(20));

        // Years
        // Months
        // Days
        // Hours
        // Minutes
        // Seconds
        // Fractions
        if (minInclusive != null) {
            if (gdurb.getYear() < minInclusive.getYear())
                gdurb.setYear(minInclusive.getYear());
            if (gdurb.getMonth() < minInclusive.getMonth())
                gdurb.setMonth(minInclusive.getMonth());
            if (gdurb.getDay() < minInclusive.getDay())
                gdurb.setDay(minInclusive.getDay());
            if (gdurb.getHour() < minInclusive.getHour())
                gdurb.setHour(minInclusive.getHour());
            if (gdurb.getMinute() < minInclusive.getMinute())
                gdurb.setMinute(minInclusive.getMinute());
            if (gdurb.getSecond() < minInclusive.getSecond())
                gdurb.setSecond(minInclusive.getSecond());
            if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0)
                gdurb.setFraction(minInclusive.getFraction());
        }

        if (maxInclusive != null) {
            if (gdurb.getYear() > maxInclusive.getYear())
                gdurb.setYear(maxInclusive.getYear());
            if (gdurb.getMonth() > maxInclusive.getMonth())
                gdurb.setMonth(maxInclusive.getMonth());
            if (gdurb.getDay() > maxInclusive.getDay())
                gdurb.setDay(maxInclusive.getDay());
            if (gdurb.getHour() > maxInclusive.getHour())
                gdurb.setHour(maxInclusive.getHour());
            if (gdurb.getMinute() > maxInclusive.getMinute())
                gdurb.setMinute(maxInclusive.getMinute());
            if (gdurb.getSecond() > maxInclusive.getSecond())
                gdurb.setSecond(maxInclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0)
                gdurb.setFraction(maxInclusive.getFraction());
        }

        if (minExclusive != null) {
            if (gdurb.getYear() <= minExclusive.getYear())
                gdurb.setYear(minExclusive.getYear() + 1);
            if (gdurb.getMonth() <= minExclusive.getMonth())
                gdurb.setMonth(minExclusive.getMonth() + 1);
            if (gdurb.getDay() <= minExclusive.getDay())
                gdurb.setDay(minExclusive.getDay() + 1);
            if (gdurb.getHour() <= minExclusive.getHour())
                gdurb.setHour(minExclusive.getHour() + 1);
            if (gdurb.getMinute() <= minExclusive.getMinute())
                gdurb.setMinute(minExclusive.getMinute() + 1);
            if (gdurb.getSecond() <= minExclusive.getSecond())
                gdurb.setSecond(minExclusive.getSecond() + 1);
            if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0)
                gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001)));
        }

        if (maxExclusive != null) {
            if (gdurb.getYear() > maxExclusive.getYear())
                gdurb.setYear(maxExclusive.getYear());
            if (gdurb.getMonth() > maxExclusive.getMonth())
                gdurb.setMonth(maxExclusive.getMonth());
            if (gdurb.getDay() > maxExclusive.getDay())
                gdurb.setDay(maxExclusive.getDay());
            if (gdurb.getHour() > maxExclusive.getHour())
                gdurb.setHour(maxExclusive.getHour());
            if (gdurb.getMinute() > maxExclusive.getMinute())
                gdurb.setMinute(maxExclusive.getMinute());
            if (gdurb.getSecond() > maxExclusive.getSecond())
                gdurb.setSecond(maxExclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0)
                gdurb.setFraction(maxExclusive.getFraction());
        }

        gdurb.normalize();
        return gdurb.toString();
    }
View Full Code Here

                    Assert.assertTrue("Problem with " + str2 + ": " + e.getMessage(), false);
                }

                // subtracting two ways works
                GDuration diff = gd.subtract(gd2);
                GDurationBuilder gdb = new GDurationBuilder(gd2);
                gdb.setSign(-gdb.getSign());
                gdb.addGDuration(gd);
                GDuration sum2 = gdb.toGDuration();
                Assert.assertEquals(0, diff.compareToGDuration(sum2));
                gdb.normalize();
                GDurationBuilder gdb1 = new GDurationBuilder(diff);
                gdb1.normalize();
                Assert.assertEquals("Problem: " + gd + " and " + gd2, gdb.toString(), gdb1.toString());


                // comparing is reversible
                int comp1 = gd.compareToGDuration(gd2);
                int comp2 = gd2.compareToGDuration(gd);
View Full Code Here

        d = (XmlDuration) sType.getFacet(SchemaType.FACET_MAX_EXCLUSIVE);
        GDuration maxExclusive = null;
        if (d != null)
            maxExclusive = d.getGDurationValue();

        GDurationBuilder gdurb = new GDurationBuilder();
        BigInteger min, max;

        gdurb.setSecond(pick(800000));
        gdurb.setMonth(pick(20));

        // Years
        // Months
        // Days
        // Hours
        // Minutes
        // Seconds
        // Fractions
        if (minInclusive != null)
        {
            if (gdurb.getYear() < minInclusive.getYear())
                gdurb.setYear(minInclusive.getYear());
            if (gdurb.getMonth() < minInclusive.getMonth())
                gdurb.setMonth(minInclusive.getMonth());
            if (gdurb.getDay() < minInclusive.getDay())
                gdurb.setDay(minInclusive.getDay());
            if (gdurb.getHour() < minInclusive.getHour())
                gdurb.setHour(minInclusive.getHour());
            if (gdurb.getMinute() < minInclusive.getMinute())
                gdurb.setMinute(minInclusive.getMinute());
            if (gdurb.getSecond() < minInclusive.getSecond())
                gdurb.setSecond(minInclusive.getSecond());
            if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0)
                gdurb.setFraction(minInclusive.getFraction());
        }

        if (maxInclusive != null)
        {
            if (gdurb.getYear() > maxInclusive.getYear())
                gdurb.setYear(maxInclusive.getYear());
            if (gdurb.getMonth() > maxInclusive.getMonth())
                gdurb.setMonth(maxInclusive.getMonth());
            if (gdurb.getDay() > maxInclusive.getDay())
                gdurb.setDay(maxInclusive.getDay());
            if (gdurb.getHour() > maxInclusive.getHour())
                gdurb.setHour(maxInclusive.getHour());
            if (gdurb.getMinute() > maxInclusive.getMinute())
                gdurb.setMinute(maxInclusive.getMinute());
            if (gdurb.getSecond() > maxInclusive.getSecond())
                gdurb.setSecond(maxInclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0)
                gdurb.setFraction(maxInclusive.getFraction());
        }

        if (minExclusive != null)
        {
            if (gdurb.getYear() <= minExclusive.getYear())
                gdurb.setYear(minExclusive.getYear()+1);
            if (gdurb.getMonth() <= minExclusive.getMonth())
                gdurb.setMonth(minExclusive.getMonth()+1);
            if (gdurb.getDay() <= minExclusive.getDay())
                gdurb.setDay(minExclusive.getDay()+1);
            if (gdurb.getHour() <= minExclusive.getHour())
                gdurb.setHour(minExclusive.getHour()+1);
            if (gdurb.getMinute() <= minExclusive.getMinute())
                gdurb.setMinute(minExclusive.getMinute()+1);
            if (gdurb.getSecond() <= minExclusive.getSecond())
                gdurb.setSecond(minExclusive.getSecond()+1);
            if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0)
                gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal(0.001)));
        }

        if (maxExclusive != null)
        {
            if (gdurb.getYear() > maxExclusive.getYear())
                gdurb.setYear(maxExclusive.getYear());
            if (gdurb.getMonth() > maxExclusive.getMonth())
                gdurb.setMonth(maxExclusive.getMonth());
            if (gdurb.getDay() > maxExclusive.getDay())
                gdurb.setDay(maxExclusive.getDay());
            if (gdurb.getHour() > maxExclusive.getHour())
                gdurb.setHour(maxExclusive.getHour());
            if (gdurb.getMinute() > maxExclusive.getMinute())
                gdurb.setMinute(maxExclusive.getMinute());
            if (gdurb.getSecond() > maxExclusive.getSecond())
                gdurb.setSecond(maxExclusive.getSecond());
            if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0)
                gdurb.setFraction(maxExclusive.getFraction());
        }

        gdurb.normalize();
        return gdurb.toString();
    }
View Full Code Here

        GDuration maxExclusive = null;
        if (d != null) {
            maxExclusive = d.getGDurationValue();
        }

        GDurationBuilder gdurb = new GDurationBuilder();
        @SuppressWarnings("unused")
        BigInteger min, max;

        gdurb.setSecond(pick(800000));
        gdurb.setMonth(pick(20));

        // Years
        // Months
        // Days
        // Hours
        // Minutes
        // Seconds
        // Fractions
        if (minInclusive != null) {
            if (gdurb.getYear() < minInclusive.getYear()) {
                gdurb.setYear(minInclusive.getYear());
            }
            if (gdurb.getMonth() < minInclusive.getMonth()) {
                gdurb.setMonth(minInclusive.getMonth());
            }
            if (gdurb.getDay() < minInclusive.getDay()) {
                gdurb.setDay(minInclusive.getDay());
            }
            if (gdurb.getHour() < minInclusive.getHour()) {
                gdurb.setHour(minInclusive.getHour());
            }
            if (gdurb.getMinute() < minInclusive.getMinute()) {
                gdurb.setMinute(minInclusive.getMinute());
            }
            if (gdurb.getSecond() < minInclusive.getSecond()) {
                gdurb.setSecond(minInclusive.getSecond());
            }
            if (gdurb.getFraction().compareTo(minInclusive.getFraction()) < 0) {
                gdurb.setFraction(minInclusive.getFraction());
            }
        }

        if (maxInclusive != null) {
            if (gdurb.getYear() > maxInclusive.getYear()) {
                gdurb.setYear(maxInclusive.getYear());
            }
            if (gdurb.getMonth() > maxInclusive.getMonth()) {
                gdurb.setMonth(maxInclusive.getMonth());
            }
            if (gdurb.getDay() > maxInclusive.getDay()) {
                gdurb.setDay(maxInclusive.getDay());
            }
            if (gdurb.getHour() > maxInclusive.getHour()) {
                gdurb.setHour(maxInclusive.getHour());
            }
            if (gdurb.getMinute() > maxInclusive.getMinute()) {
                gdurb.setMinute(maxInclusive.getMinute());
            }
            if (gdurb.getSecond() > maxInclusive.getSecond()) {
                gdurb.setSecond(maxInclusive.getSecond());
            }
            if (gdurb.getFraction().compareTo(maxInclusive.getFraction()) > 0) {
                gdurb.setFraction(maxInclusive.getFraction());
            }
        }

        if (minExclusive != null) {
            if (gdurb.getYear() <= minExclusive.getYear()) {
                gdurb.setYear(minExclusive.getYear() + 1);
            }
            if (gdurb.getMonth() <= minExclusive.getMonth()) {
                gdurb.setMonth(minExclusive.getMonth() + 1);
            }
            if (gdurb.getDay() <= minExclusive.getDay()) {
                gdurb.setDay(minExclusive.getDay() + 1);
            }
            if (gdurb.getHour() <= minExclusive.getHour()) {
                gdurb.setHour(minExclusive.getHour() + 1);
            }
            if (gdurb.getMinute() <= minExclusive.getMinute()) {
                gdurb.setMinute(minExclusive.getMinute() + 1);
            }
            if (gdurb.getSecond() <= minExclusive.getSecond()) {
                gdurb.setSecond(minExclusive.getSecond() + 1);
            }
            if (gdurb.getFraction().compareTo(minExclusive.getFraction()) <= 0) {
                gdurb.setFraction(minExclusive.getFraction().add(new BigDecimal("0.001")));
            }
        }

        if (maxExclusive != null) {
            if (gdurb.getYear() > maxExclusive.getYear()) {
                gdurb.setYear(maxExclusive.getYear());
            }
            if (gdurb.getMonth() > maxExclusive.getMonth()) {
                gdurb.setMonth(maxExclusive.getMonth());
            }
            if (gdurb.getDay() > maxExclusive.getDay()) {
                gdurb.setDay(maxExclusive.getDay());
            }
            if (gdurb.getHour() > maxExclusive.getHour()) {
                gdurb.setHour(maxExclusive.getHour());
            }
            if (gdurb.getMinute() > maxExclusive.getMinute()) {
                gdurb.setMinute(maxExclusive.getMinute());
            }
            if (gdurb.getSecond() > maxExclusive.getSecond()) {
                gdurb.setSecond(maxExclusive.getSecond());
            }
            if (gdurb.getFraction().compareTo(maxExclusive.getFraction()) > 0) {
                gdurb.setFraction(maxExclusive.getFraction());
            }
        }

        gdurb.normalize();
        return gdurb.toString();
    }
View Full Code Here

                    Assert.assertTrue("Problem with " + str2 + ": " + e.getMessage(), false);
                }

                // subtracting two ways works
                GDuration diff = gd.subtract(gd2);
                GDurationBuilder gdb = new GDurationBuilder(gd2);
                gdb.setSign(-gdb.getSign());
                gdb.addGDuration(gd);
                GDuration sum2 = gdb.toGDuration();
                Assert.assertEquals(0, diff.compareToGDuration(sum2));
                gdb.normalize();
                GDurationBuilder gdb1 = new GDurationBuilder(diff);
                gdb1.normalize();
                Assert.assertEquals("Problem: " + gd + " and " + gd2, gdb.toString(), gdb1.toString());


                // comparing is reversible
                int comp1 = gd.compareToGDuration(gd2);
                int comp2 = gd2.compareToGDuration(gd);
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.GDurationBuilder

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.