Package org.joda.time

Examples of org.joda.time.DateTime


    }

    //-----------------------------------------------------------------------
    public void test_setYear() {
        Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
        DateTime dt = new DateTime(2007, 1, 1, 0, 0 ,0, 0, zone);
        assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
        dt = dt.withYear(2008);
        assertEquals("2008-01-01T00:00:00.000Z", dt.toString());
    }
View Full Code Here


    }

    //-----------------------------------------------------------------------
    public void test_setMonthOfYear() {
        Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
        DateTime dt = new DateTime(2007, 1, 1, 0, 0 ,0, 0, zone);
        assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
        dt = dt.withMonthOfYear(13);
        assertEquals("2008-01-01T00:00:00.000Z", dt.toString());
        dt = dt.withMonthOfYear(0);
        assertEquals("2007-12-01T00:00:00.000Z", dt.toString());
    }
View Full Code Here

    }

    //-----------------------------------------------------------------------
    public void test_setDayOfMonth() {
        Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
        DateTime dt = new DateTime(2007, 1, 1, 0, 0 ,0, 0, zone);
        assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
        dt = dt.withDayOfMonth(32);
        assertEquals("2007-02-01T00:00:00.000Z", dt.toString());
        dt = dt.withDayOfMonth(0);
        assertEquals("2007-01-31T00:00:00.000Z", dt.toString());
    }
View Full Code Here

    }

    //-----------------------------------------------------------------------
    public void test_setHourOfDay() {
        Chronology zone = LenientChronology.getInstance(ISOChronology.getInstanceUTC());
        DateTime dt = new DateTime(2007, 1, 1, 0, 0 ,0, 0, zone);
        assertEquals("2007-01-01T00:00:00.000Z", dt.toString());
        dt = dt.withHourOfDay(24);
        assertEquals("2007-01-02T00:00:00.000Z", dt.toString());
        dt = dt.withHourOfDay(-1);
        assertEquals("2007-01-01T23:00:00.000Z", dt.toString());
    }
View Full Code Here

    //-----------------------------------------------------------------------
    public void testNearDstTransition() {
        // This is just a regression test. Test case provided by Blair Martin.

        int hour = 23;
        DateTime dt;

        dt = new DateTime(2006, 10, 29, hour, 0, 0, 0,
                          ISOChronology.getInstance(DateTimeZone.forID("America/Los_Angeles")));
        assertEquals(hour, dt.getHourOfDay()); // OK - no LenientChronology

        dt = new DateTime(2006, 10, 29, hour, 0, 0, 0,
                          LenientChronology.getInstance
                          (ISOChronology.getInstance(DateTimeZone.forOffsetHours(-8))));
        assertEquals(hour, dt.getHourOfDay()); // OK - no TZ ID

        dt = new DateTime(2006, 10, 29, hour, 0, 0, 0,
                          LenientChronology.getInstance
                          (ISOChronology.getInstance(DateTimeZone.forID("America/Los_Angeles"))));

        assertEquals(hour, dt.getHourOfDay()); // Used to fail - hour was 22
    }
View Full Code Here

    private static int OFFSET_TURK = -18000000// -05:00
    private static final DateTimeZone MOCK_TURK = new MockZone(CUTOVER_TURK, OFFSET_TURK, 3600);

    //-----------------------------------------------------------------------
    public void test_MockTurkIsCorrect() {
        DateTime pre = new DateTime(CUTOVER_TURK - 1L, MOCK_TURK);
        assertEquals("2007-03-31T23:59:59.999-05:00", pre.toString());
        DateTime at = new DateTime(CUTOVER_TURK, MOCK_TURK);
        assertEquals("2007-04-01T01:00:00.000-04:00", at.toString());
        DateTime post = new DateTime(CUTOVER_TURK + 1L, MOCK_TURK);
        assertEquals("2007-04-01T01:00:00.001-04:00", post.toString());
    }
View Full Code Here

    }

    public void test_lenientChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = LenientChronology.getInstance(ISOChronology.getInstance(zone));
        DateTime dt = new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
        assertEquals("2007-03-11T03:30:00.000-05:00", dt.toString());
    }
View Full Code Here

        assertEquals("2007-03-11T03:30:00.000-05:00", dt.toString());
    }

    public void test_lenientChrononolgy_Turk() {
        Chronology lenient = LenientChronology.getInstance(ISOChronology.getInstance(MOCK_TURK));
        DateTime dt = new DateTime(2007, 4, 1, 0, 30, 0, 0, lenient);
        assertEquals("2007-04-01T01:30:00.000-04:00", dt.toString());
    }
View Full Code Here

    public void test_strictChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = StrictChronology.getInstance(ISOChronology.getInstance(zone));
        try {
            new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
            fail();
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

    public void test_isoChrononolgy_Chicago() {
        DateTimeZone zone = DateTimeZone.forID("America/Chicago");
        Chronology lenient = ISOChronology.getInstance(zone);
        try {
            new DateTime(2007, 3, 11, 2, 30, 0, 0, lenient);
            fail();
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of org.joda.time.DateTime

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.