Examples of GDate


Examples of org.apache.xmlbeans.GDate

    }

    public static void validateValue(GDateSpecification v, SchemaType sType, ValidationContext context)
    {
        XmlObject x;
        GDate g;
       
        if (v.getBuiltinTypeCode() != sType.getPrimitiveType().getBuiltinTypeCode())
            context.invalid("Date (" + v + ") does not have the set of fields required for " + QNameHelper.readable(sType));

        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
View Full Code Here

Examples of org.apache.xmlbeans.GDate

    protected void set_GDate(GDateSpecification v)
    {
        int code = schemaType().getPrimitiveType().getBuiltinTypeCode();

        GDate candidate;

        if (v.isImmutable() && (v instanceof GDate) && v.getBuiltinTypeCode() == code)
            candidate = (GDate)v;
        else
        {
            // truncate extra fields from the date if necessary.
            if (v.getBuiltinTypeCode() != code)
            {
                GDateBuilder gDateBuilder = new GDateBuilder(v);
                gDateBuilder.setBuiltinTypeCode(code);
                v = gDateBuilder;
            }
            candidate = new GDate(v);
        }

        if (_validateOnSet())
            validateValue(candidate, _schemaType, _voorVc);
View Full Code Here

Examples of org.apache.xmlbeans.GDate

    {
        int code = schemaType().getPrimitiveType().getBuiltinTypeCode();

        GDateBuilder gDateBuilder = new GDateBuilder(c);
        gDateBuilder.setBuiltinTypeCode(code);
        GDate value = gDateBuilder.toGDate();
        if (_validateOnSet())
            validateValue(value, _schemaType, _voorVc);

        _value = value;
View Full Code Here

Examples of org.apache.xmlbeans.GDate

            v == null)
            throw new XmlValueOutOfRangeException();

        GDateBuilder gDateBuilder = new GDateBuilder(v);
        gDateBuilder.setBuiltinTypeCode(code);
        GDate value = gDateBuilder.toGDate();
        if (_validateOnSet())
            validateValue(value, _schemaType, _voorVc);

        _value = value;
View Full Code Here

Examples of org.apache.xmlbeans.GDate

    }
   
    public static void testGregorianCalendar()
    {
        // this is a check of DST offsets
        Date date = new GDate("2002-04-18T23:59:59Z").getDate();
        GregorianCalendar gcal = new XmlCalendar(date);
        Assert.assertEquals(date, gcal.getTime());

        // now check out some things
        GDate gd = new GDate("2001-12-31T07:00:59.010");
        GregorianCalendar gc = gd.getCalendar();
        Date gdd = gd.getDate();
        Date gcd = gc.getTime();
        Assert.assertEquals(gdd, gcd);
       
        // set up 2/29, and read out Feb 29 in the year 1 BC.
        XmlCalendar gregcal = new GDate("--02-29").getCalendar();
        Assert.assertEquals(29, gregcal.peek(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(2 - 1, gregcal.peek(Calendar.MONTH));
        Assert.assertEquals(1, gregcal.peek(Calendar.YEAR));
        Assert.assertEquals(0, gregcal.peek(Calendar.ERA));
        // repeat some tests to make sure it's stable.
        Assert.assertEquals(29, gregcal.peek(Calendar.DAY_OF_MONTH));
        Assert.assertEquals(2 - 1, gregcal.peek(Calendar.MONTH));

        // now try some setters
        gregcal = new GDate("--02-29").getCalendar();
        gregcal.set(Calendar.MONTH, 10);
        Assert.assertEquals("--11-29", gregcal.toString());
        // repeat to ensure it's stable.
        Assert.assertEquals("--11-29", gregcal.toString());
    }
View Full Code Here

Examples of org.apache.xmlbeans.GDate

                // comparing translates to addition to dates
                boolean[] seen = new boolean[3];

                for (int k = 0; k < validDates.length; k++)
                {
                    GDate date = new GDate(validDates[k]);
                    if (!date.hasDate() || date.getYear() > 99999 || date.getYear() < -4000)
                        continue;
                    if ((hasTime(gd) || hasTime(gd2)) && !date.hasTime())
                        continue;
                    // System.out.println("Adding " + gd + " and " + gd2 + " to " + date + ", expecting " + comp1);
                    GDate date1 = date.add(gd);
                    GDate date2 = date.add(gd2);

                    comp2 = date1.compareToGDate(date2);
                    if (comp1 != 2)
                    {
                        Assert.assertEquals("Adding " + date + " + " + gd + " -> " + date1 + ", " + gd2 + " -> " + date2 + ", expecting " + comp1, comp1, comp2);
                    }
                    else
                    {
                        Assert.assertTrue(comp2 != 2);
                        seen[comp2 + 1] = true;
                    }

                    // subtraction should yeild the same result
                    if (comp1 != 2)
                    {
                        GDate date3 = date.add(diff);
                        Assert.assertEquals(comp1, date3.compareToGDate(date));
                    }
                }

                if (comp1 == 2)
                {
View Full Code Here

Examples of org.apache.xmlbeans.GDate

        }
    }

    public static void testOrder()
    {
        Assert.assertEquals(-1, new GDate("1998-08-26").compareToGDate(new GDate("2001-08-06")));
        Assert.assertEquals(-1, new GDate("1970-12-20T04:14:22Z").compareToGDate(new GDate("1971-04-18T12:51:41Z")));
        Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-06Z")));
        Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-07+10:00")));
        Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-05-10:00")));
        Assert.assertEquals(2, new GDate("2001-02-28").compareToGDate(new GDate("2001-03-01+10:00")));
        Assert.assertEquals(2, new GDate("2001-03-01").compareToGDate(new GDate("2001-02-28-10:00")));
        Assert.assertEquals(-1, new GDate("2000-02-28").compareToGDate(new GDate("2000-03-01+10:00")));
        Assert.assertEquals(1, new GDate("2000-03-01").compareToGDate(new GDate("2000-02-28-10:00")));
        Assert.assertEquals(-1, new GDate("2001-08-06Z").compareToGDate(new GDate("2001-08-06-00:01")));
        Assert.assertEquals(0, new GDate("00:00:00Z").compareToGDate(new GDate("00:01:00+00:01")));
        Assert.assertEquals(0, new GDate("12:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00")));
        Assert.assertEquals(-1, new GDate("09:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00"))); // the east coast rises before the west
        Assert.assertEquals(-1, new GDate("2003-05-05T09:00:00-05:00").compareToGDate(new GDate("2003-05-05T09:00:00-08:00"))); // the east coast rises before the west
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31")));
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31+14:00")));
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31-14:00")));
        Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01")));
        Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01+14:00")));
        Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01-14:00")));
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02")));
        Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01")));
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02Z")));
        Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01Z")));
        Assert.assertEquals(2, new GDate("---02").compareToGDate(new GDate("---01-10:00")));
        Assert.assertEquals(2, new GDate("---01").compareToGDate(new GDate("---02+10:00")));
        Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01-09:00")));
        Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02+09:00")));
        Assert.assertEquals(0, new GDate("---01").compareToGDate(new GDate("---01")));
        Assert.assertEquals(-1, new GDate("2003").compareToGDate(new GDate("2004")));
        Assert.assertEquals(-1, new GDate("--11").compareToGDate(new GDate("--12")));
        Assert.assertEquals(-1, new GDate("2003-12").compareToGDate(new GDate("2004-01")));
        Assert.assertEquals(-1, new GDate("--11-30").compareToGDate(new GDate("--12-01")));
        Assert.assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--02-29")));
        Assert.assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01")));
        Assert.assertEquals(2, new GDate("--02-29").compareToGDate(new GDate("--03-01+10:00")));
        Assert.assertEquals(2, new GDate("--02-28").compareToGDate(new GDate("--03-01+10:00")));
        Assert.assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-28-10:00")));
        Assert.assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-29-10:00")));
        Assert.assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01+09:00")));
        Assert.assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--03-01+09:00")));
        Assert.assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-28-09:00")));
        Assert.assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-29-09:00")));
        Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59")));
        Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+09:59")));
        Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:01+09:59")));
        Assert.assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:00+09:59")));
        Assert.assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+10:00")));
        Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59-14:00")));
        Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-09:59")));
        Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:58-09:59")));
        Assert.assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:59-09:59")));
        Assert.assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-10:00")));
        Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00+14:00")));
    }
View Full Code Here

Examples of org.apache.xmlbeans.GDate

        for (int i = 0; i < invalidDates.length; i++)
        {
            String str = invalidDates[i];
            try
            {
                new GDate(str);
            }
            catch (IllegalArgumentException e)
            {
                continue;
            }
View Full Code Here

Examples of org.apache.xmlbeans.GDate

    public static void testSuccess() throws Exception
    {
        for (int i = 0; i < validDates.length; i++)
        {
            String str = validDates[i];
            GDate gdate = null;
            try
            {
                gdate = new GDate(str);
            }
            catch (IllegalArgumentException e)
            {
                Assert.assertTrue("Problem with " + str + ": " + e.getMessage(), false);
            }

            // must round-trip to string
            Assert.assertEquals(str, gdate.toString());

            // must round-trip to GregorianCalendar if fractions-of-seconds <=3 digits
            if (gdate.getFraction() == null || gdate.getFraction().scale() <= 3)
                if (!gdate.toString().equals("--02-29")) // bug in gcal -> 03-01
            {
                GregorianCalendar gcal = gdate.getCalendar();
                GDate gdate2 = new GDate(gcal);
                Assert.assertEquals(gdate, gdate2);

                // and if fractions-of-seconds is 3 digits, stringrep must round-trip
                if (gdate.getFraction() == null || gdate.getFraction().scale() == 3 || gdate.getFraction().scale() == 0)
                    Assert.assertEquals(gdate.toString(), gdate2.toString());
            }

            // must round-trip to Date if absolute time+timezone + fractions-of-seconds <= 3
            if (gdate.hasTimeZone() && gdate.getYear() > -4000 && gdate.getYear() < 99999 && gdate.getBuiltinTypeCode() == SchemaType.BTC_DATE_TIME && gdate.getFraction().scale() <= 3)
            {
                Date date = gdate.getDate();
                GDate gdate2 = new GDate(date);
                Assert.assertEquals(gdate, gdate2);
               
                // normalize to UTC fractions-of-seconds is 0 or 3 digits [not 000], stringrep must round-trip
                if (gdate.getTimeZoneSign() == 0 && ((gdate.getFraction().scale() == 3 && gdate.getFraction().signum() != 0) || gdate.getFraction().scale() == 0))
                {
View Full Code Here

Examples of org.apache.xmlbeans.GDate

        case SchemaType.BTC_G_YEAR :
        case SchemaType.BTC_G_MONTH_DAY :
        case SchemaType.BTC_G_DAY :
        case SchemaType.BTC_G_MONTH :
        {
            GDate d = XmlDateImpl.validateLexical( value, type, _vc );

            if (d != null)
                XmlDateImpl.validateValue( d, type, _vc );

            _gdateValue = d;
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.