Search in sources :

Example 36 with Chronology

use of org.joda.time.Chronology in project joda-time by JodaOrg.

the class TestConverterManager method testGetInstantConverterOKMultipleMatches.

public void testGetInstantConverterOKMultipleMatches() {
    InstantConverter c = new InstantConverter() {

        public long getInstantMillis(Object object, Chronology chrono) {
            return 0;
        }

        public Chronology getChronology(Object object, DateTimeZone zone) {
            return null;
        }

        public Chronology getChronology(Object object, Chronology chrono) {
            return null;
        }

        public Class getSupportedType() {
            return ReadableDateTime.class;
        }
    };
    try {
        ConverterManager.getInstance().addInstantConverter(c);
        InstantConverter ok = ConverterManager.getInstance().getInstantConverter(new DateTime());
        // ReadableDateTime and ReadableInstant both match, but RI discarded as less specific
        assertEquals(ReadableDateTime.class, ok.getSupportedType());
    } finally {
        ConverterManager.getInstance().removeInstantConverter(c);
    }
    assertEquals(6, ConverterManager.getInstance().getInstantConverters().length);
}
Also used : ReadableDateTime(org.joda.time.ReadableDateTime) Chronology(org.joda.time.Chronology) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) ReadableDateTime(org.joda.time.ReadableDateTime)

Example 37 with Chronology

use of org.joda.time.Chronology in project joda-time by JodaOrg.

the class TestISOChronology method testLeap_28feb.

public void testLeap_28feb() {
    Chronology chrono = ISOChronology.getInstance();
    DateTime dt = new DateTime(2012, 2, 28, 0, 0, chrono);
    assertEquals(true, dt.year().isLeap());
    assertEquals(true, dt.monthOfYear().isLeap());
    assertEquals(false, dt.dayOfMonth().isLeap());
    assertEquals(false, dt.dayOfYear().isLeap());
}
Also used : Chronology(org.joda.time.Chronology) DateTime(org.joda.time.DateTime)

Example 38 with Chronology

use of org.joda.time.Chronology in project joda-time by JodaOrg.

the class TestJulianChronology method testLeap_29feb.

public void testLeap_29feb() {
    Chronology chrono = JulianChronology.getInstance();
    DateTime dt = new DateTime(2012, 2, 29, 0, 0, chrono);
    assertEquals(true, dt.year().isLeap());
    assertEquals(true, dt.monthOfYear().isLeap());
    assertEquals(true, dt.dayOfMonth().isLeap());
    assertEquals(true, dt.dayOfYear().isLeap());
}
Also used : Chronology(org.joda.time.Chronology) DateTime(org.joda.time.DateTime)

Example 39 with Chronology

use of org.joda.time.Chronology in project joda-time by JodaOrg.

the class TestLenientChronology method test_lenientChrononolgy_Chicago.

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());
}
Also used : Chronology(org.joda.time.Chronology) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Example 40 with Chronology

use of org.joda.time.Chronology in project joda-time by JodaOrg.

the class TestLenientChronology method test_strictChrononolgy_Chicago.

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
    }
}
Also used : Chronology(org.joda.time.Chronology) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Aggregations

Chronology (org.joda.time.Chronology)69 DateTime (org.joda.time.DateTime)32 ISOChronology (org.joda.time.chrono.ISOChronology)30 GJChronology (org.joda.time.chrono.GJChronology)18 BuddhistChronology (org.joda.time.chrono.BuddhistChronology)17 LocalDate (org.joda.time.LocalDate)14 DateTimeZone (org.joda.time.DateTimeZone)13 MutableDateTime (org.joda.time.MutableDateTime)7 LocalDateTime (org.joda.time.LocalDateTime)4 ReadableDateTime (org.joda.time.ReadableDateTime)4 JulianChronology (org.joda.time.chrono.JulianChronology)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 Serializable (java.io.Serializable)2 Date (java.util.Date)2 Duration (org.joda.time.Duration)2 Period (org.joda.time.Period)2 ReadableDuration (org.joda.time.ReadableDuration)2 ReadableInstant (org.joda.time.ReadableInstant)2 ReadablePartial (org.joda.time.ReadablePartial)2 Calendar (java.util.Calendar)1