Package org.joda.time

Examples of org.joda.time.LocalDate


     */
    public static LocalDate deserializeLocalDate(String text) throws JiBXException {
        if (text == null) {
            return null;
        } else {
            return new LocalDate(Utility.parseDate(text), DateTimeZone.UTC);
        }
    }
View Full Code Here


        DateTimeZone.setDefault(DateTimeZone.forOffsetHours(OFFSET_HOURS));
    }

    public void testDeserializeLocalDate() throws JiBXException {
        assertNull("Null input", JodaConvert.deserializeLocalDate(null));
        LocalDate date = JodaConvert.deserializeLocalDate("2008-02-28");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 28, date.getDayOfMonth());
        date = JodaConvert.deserializeLocalDate("2008-02-29Z");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        date = JodaConvert.deserializeLocalDate("2008-02-29-24:00");
        assertEquals("Wrong value", 2008, date.getYear());
        assertEquals("Wrong value", 2, date.getMonthOfYear());
        assertEquals("Wrong value", 29, date.getDayOfMonth());
        try {
            JodaConvert.deserializeUTCDateTime("2007-02-29");
            fail("Invalid day number");
        } catch (JiBXException ex) {}
        try {
View Full Code Here

            fail("Invalid month number");
        } catch (JiBXException ex) {}
    }
   
    public void testSerializeLocalDate() throws JiBXException {
        assertEquals("2008-02-28", JodaConvert.serializeLocalDate(new LocalDate(2008, 2, 28)));
        assertEquals("2008-02-29", JodaConvert.serializeLocalDate(new LocalDate(2008, 2, 29)));
        assertEquals("2008-03-01", JodaConvert.serializeLocalDate(new LocalDate(2008, 3, 1)));
    }
View Full Code Here

    //-----------------------------------------------------------------------
    private static final Chronology GJ_CHRONOLOGY = GJChronology.getInstanceUTC();

    //-----------------------------------------------------------------------
    public void test_plusYears_positiveToPositive() {
        LocalDate date = new LocalDate(3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(7, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(4));
    }
View Full Code Here

        LocalDate expected = new LocalDate(7, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(4));
    }

    public void test_plusYears_positiveToZero() {
        LocalDate date = new LocalDate(3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(-1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(-3));
    }
View Full Code Here

        LocalDate expected = new LocalDate(-1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(-3));
    }

    public void test_plusYears_positiveToNegative() {
        LocalDate date = new LocalDate(3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(-2, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(-4));
    }
View Full Code Here

        assertEquals(expected, date.plusYears(-4));
    }

    //-----------------------------------------------------------------------
    public void test_plusYears_negativeToNegative() {
        LocalDate date = new LocalDate(-3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(-1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(2));
    }
View Full Code Here

        LocalDate expected = new LocalDate(-1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(2));
    }

    public void test_plusYears_negativeToZero() {
        LocalDate date = new LocalDate(-3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(3));
    }
View Full Code Here

        LocalDate expected = new LocalDate(1, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(3));
    }

    public void test_plusYears_negativeToPositive() {
        LocalDate date = new LocalDate(-3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(2, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(4));
    }
View Full Code Here

        assertEquals(expected, date.plusYears(4));
    }

    //-----------------------------------------------------------------------
    public void test_plusYears_positiveToPositive_crossCutover() {
        LocalDate date = new LocalDate(3, 6, 30, GJ_CHRONOLOGY);
        LocalDate expected = new LocalDate(2007, 6, 30, GJ_CHRONOLOGY);
        assertEquals(expected, date.plusYears(2004));
    }
View Full Code Here

TOP

Related Classes of org.joda.time.LocalDate

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.